<?php

defined('HDSYS_SET') or die("" . 'Not,This File Not Can in Ie Open');





/**
 * 后端功能类目 2021.8.20 小周
 */

class templates
{
	public $intelligence_templates_dir = '';
	public $intelligence_FileTemplatescContent = '';

	public $intelligence_db;



	/*构造函数 //'<?php include ("\\1.hdsys.php"); ?>',*/
	public function __construct()
	{
		$this->intelligence_db = bs_lib::load_libhdsys_class("" . 'db');



		// $this->intelligence_templates_dir =  bs_lib::get_configs_value("" . 'template', "" . 'current');
		// if ($this->intelligence_templates_dir == '') {
		// 	$this->intelligence_templates_dir = "" . 'default';
		// }

		$this->intelligence_templates_dir = intelligence_get_templates_dir();
	}

	// public function intelligence_templates_dir()
	// {
	//     return 'templates';
	// }

	//读取某个模版
	public function GetTemplatesFile($param_dir_file, &$param_back)
	{



		$param_back = '200';
		// $param_name = $param_dir_file . "" . '.code.php';
		// $param_File_Name = HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/' . $param_name;
		// //代码模式判断防止可视化模式替换
		// if (file_exists($param_File_Name)) {
		// 	$param_File_Data = file_get_contents($param_File_Name);
		// 	return $param_File_Data;
		// }

		// //替换中英文
		// $param_name = $param_dir_file . "" . '.code.php';
		// $param_File_Name = HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/' . $param_name;
		// //代码模式判断防止可视化模式替换
		// if (file_exists($param_File_Name)) {
		// 	$param_File_Data = file_get_contents($param_File_Name);
		// 	return $param_File_Data;
		// }





		$param_dir_file = safe_replace_file($param_dir_file);
		$param_name = $param_dir_file . "" . '.hdsys.php';
		$param_File_Name = HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/' . $param_name;



		if (!file_exists($param_File_Name)) {
			$param_back = '404';
			$param_File_404 = HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/' . '404' . '.hdsys.php';

			if (file_exists($param_File_404)) {
				$param_File_Data = file_get_contents($param_File_404);
				$param_File_Data = call_my_str_replace('{$FILE_NAME}', $param_File_Name, $param_File_Data);
				return $param_File_Data;
			}


			if (!preg_match('/^[a-zA-Z0-9\._-]+$/', $param_dir_file, $param_daata)) {

				//print_r($_SERVER['REQUEST_URI']);
				header('HTTP/1.1 404 Not Found');
				return '<script> window.CODE = "1000"  </script> <a id="maginfo" style="color: #CC5522;" >访问地址错误404:' . substr(getsysurl(), 0, -1) . $_SERVER['REQUEST_URI'] . ' ' . time() . '<a>';
				return (0);
			}




			//隐藏根目录
			$param_File_Data = call_my_str_replace(HDSYS_DIR_SYS, $param_File_Name, $param_File_Name);
			if (get_session_value('DIV_MEIN') == 1) {



				return '<script> window.CODE = "1000"  </script> <a id="maginfo" style="color: #CC5522;" >[可视化开发模式 模版不存在:' . "{$param_File_Name}" . '] ' . time() . '<a>';
			} else {


				// if($param_dir_file=='content.jmp'){
				// 	echo '<head><meta http-equiv="refresh" content="0;url={$data.url}"></head>';

				// }
				return '<script> window.CODE = "1000"  </script> <a id="maginfo" style="color: #CC5522;" >[模版不存在:' . "{$param_File_Name}" . '] ' . time() . '<a>';
			}
		}





		#无需生成,判断是否需要生成

		//可视化编辑>生成模版
		$param_re = call_my_push_templates_html($param_name, $this->intelligence_templates_dir);
		if ($param_re != '') {
			echo '<a style="color: #CC5522;" >[' . $param_re . '] ' . time() . '<a>';
			exit;
		}




		$param_File_Data = file_get_contents($param_File_Name);
		return $param_File_Data;
	}



	public function GetPublicFile($param_dir_file)
	{

		$param_dir_file = safe_replace_file($param_dir_file);
		$param_File_Name = HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/Public/' . $param_dir_file . '.php';

		if (!is_file($param_File_Name)) {
			///return '<a style="color: #CC5522;" >[Public模版不存在:' . $param_File_Name . '] ' . time() . '<a>';

			return '<include file="' . $param_dir_file . '" msg="模版不存在" />';
		}
		$param_File_Data = file_get_contents($param_File_Name);
		return $param_File_Data;
	}

	//模版入口函数点，先载入主模版，在解析合并文件，在解析变量，在解析数据库
	//参数1是模版变量
	//参数2是跟随注入的变量信息
	public function Compiler($param_dir_file, $param_url_name, $data)
	{


		if ($param_url_name == '') {
			$param_url_name = 'index';
		}

		//读取主要文件
		$this->intelligence_FileTemplatescContent = $this->GetTemplatesFile($param_dir_file, $param_back);




		//载入需要模块文件include，嵌套3次
		$this->intelligence_getinclude();
		$this->intelligence_getinclude();
		$this->intelligence_getinclude();





		//嵌套3次
		//#替换系统配置项目 $config
		$this->intelligence_getconfig();
		//#替换 $get  $data $post 0=只替换{$data.name} {}的变量，不然替换出现一次后，第二次就把{$data.name} 中 $data.name 替换留下{}
		$this->intelligence_dataStr($data, 1);
		$this->intelligence_getconfig();
		$this->intelligence_dataStr($data, 0);



		//#广告模块单独获取
		$this->intelligence_getadvertisement();
		//# 新标签 导航栏目
		$this->intelligence_new_navigation($data);

		//#智能广告循环
		$this->intelligence_advertisementAs();

		//#读取部分数据库内容显示带缓存
		$this->intelligence_exhibitionAs();

		//只读不循环
		$this->intelligence_arrexhibition();

		//#列表循环
		$this->intelligence_columnAs($data);

		//#列表循环 内容列表专属
		$this->intelligence_contentAs($data, $param_url_name);



		//#替换列表上下一页
		$this->intelligence_prevnext($data);


		//#基本的if 替换 这个放最后不影响一些固定的替换
		$this->intelligence_basic1($param_url_name);


		//$this->intelligence_navactive($param_url_name);



		//处理细节
		$this->intelligence_basic2();

		//最后通用量生成
		$this->intelligence_basic3();


		//开发者模式生成
		$this->intelligence_div_mein();



		//css js存储成文件放缓存目录
		$this->intelligence_js_css();

		//可视化编辑传递信息
		$param_DIV_MEIN = (int)get_session_value('DIV_MEIN');
		if ($param_DIV_MEIN == 1) {




			$param_arr = call_my_is_visualization($this->intelligence_templates_dir);
			//判断不是可视化编辑模式部显示了
			if ($param_arr['code'] == 2) {



				$param_getsysurl = getcdnurlhost();
				$param_file = $param_dir_file . "" . '.hdsys.php';
				$param_time = time();
				$param_html = "\n<link rel='stylesheet' href='{$param_getsysurl}/DivTemplates/Hdsys-Div.css?v={$param_time}' media='all'>\n";




				$param_admin_dir = get_session_value('DIV_ADMIN_URL');
				$param_html .= "<script> window.hdsys_config = {\"file\":\"$param_file\",\"dir\":\"{$this->intelligence_templates_dir}\",\"host\":\"{$param_getsysurl}\",\"admin_dir\":\"{$param_admin_dir}\"}  </script>\n";


				//判断不是404才会返回设置的页面
				if ($param_back == 200) {
					set_session_value('DIV_MEIN_file', $param_file);
					//当前打开模版文件
				}

				set_session_value('DIV_MEIN_dir', $this->intelligence_templates_dir);



				$param_html .= "<link rel='stylesheet' href='{$param_getsysurl}/admin/layui/css/layui.css' media='all'>\n";
				$param_html .= "<script src='{$param_getsysurl}/admin/layui/layui.js'></script>\n";
				$param_html .= "<script src='{$param_getsysurl}/DivTemplates/Hdsys-Div.js'></script>\n";



				$this->intelligence_FileTemplatescContent .= $param_html;
			}
		}




		//#获取写入目录
		if ($this->intelligence_FileTemplatescContent == '') {
			$param_File_Name = HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/'  . $param_dir_file . "" . '.hdsys.php';

			echo '<a style="color: #CC5522;" >[模版没有内容缓存写入失败:' . $param_File_Name . '] ' . time() . '<a>';
			exit;
		}




		$param_file_cache = HDSYS_DIR_SYS . 'cache/templates.' . call_my_md5(getsysurl() . $param_dir_file . $_SERVER["" . 'REQUEST_URI']) . '.php';








		$param_tmp = file_put_contents($param_file_cache, $this->intelligence_FileTemplatescContent);
		if (!$param_tmp) {
			echo '<a style="color: #CC5522;" >[缓存写入失败:WEB根目录cache 目录请设置777可写属性] ' . time() . '<a>';
			exit;
		}




		return $param_file_cache;
	}



	/**
	 * @功能
	 */
	public function intelligence_getadvertisement()
	{
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\{\$advertisement\.(.*?)\.(.*?)\}#',
			function ($param_matches) {
				$param_File = HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/modular/' . $param_matches[1] . '.*.modular.php';
				$param_File_ARRAY = glob($param_File);
				if (isset($param_File_ARRAY[0])) {
					$param_arr =  include($param_File_ARRAY[0]);

					if (isset($param_arr[$param_matches[2]])) {


						if ($param_matches[2] == 'imges' or $param_matches[2] == 'eimges') {


							$param_val = $param_arr[$param_matches[2]];
							$param_val = str_replace('{__URL__}', getsysurl(), $param_val);
							$param_val = str_replace('{__TEMPLATES__}',  intelligence_get_templates_dir(), $param_val);




							return $param_val;
						} else {
							return $param_arr[$param_matches[2]];
						}
					} else {
						return '!~' . $param_matches[2] . '~!' . $param_matches[0];;
					}
				} else {
					return '!~' . $param_matches[0];
				}
			},
			$this->intelligence_FileTemplatescContent
		);
	}


	//开发者模式配置显示
	public function intelligence_js_css()
	{

		//js
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'/<script([a-zA-Z0-9_=\s\'"]+)>\s(.*?)\s<\/script>/is',
			function ($param_matches) {
				//print_r($param_matches);
				$param_array = call_my_GetDivArray($param_matches[1]);
				if (isset($param_array['long']) and $param_array['long'] == 'file') {



					$param_src_md5 = call_my_md5($param_matches[2]);

					$param_file = "cache/hdsyscms-{$param_src_md5}.js";


					@file_put_contents(HDSYS_DIR_SYS . $param_file, $param_matches[2]);


					$param_url = getsysurl() . $param_file . '?t=' . call_my_time();


					return "<script src='{$param_url}'></script>";
				}



				return $param_matches[0];
			},
			$this->intelligence_FileTemplatescContent
		);


		//css
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'/<style([a-zA-Z0-9_=\s\'\"]+)>\s(.*?)\s<\/style>/is',
			function ($param_matches) {

				$param_array = call_my_GetDivArray($param_matches[1]);
				if (isset($param_array['long']) and $param_array['long'] == 'file') {
					$param_src_md5 = call_my_md5($param_matches[2]);

					$param_file = "cache/hdsyscms-{$param_src_md5}.css";


					@file_put_contents(HDSYS_DIR_SYS . $param_file, $param_matches[2]);


					$param_url = getsysurl() . $param_file . '?t=' . call_my_time();


					if (isset($param_array['rel']) and $param_array['rel'] != '') {

						$param_rel = "rel=\"{$param_array['rel']}\"";
					} else {
						$param_rel = "rel=\"stylesheet\"";
					}


					return "<link href=\"{$param_url}\" rel=\"stylesheet\"  >";
				}



				return $param_matches[0];
			},
			$this->intelligence_FileTemplatescContent
		);
	}

	//开发者模式配置显示
	public function intelligence_div_mein()
	{

		$param_DIV_MEIN = (int)get_session_value('DIV_MEIN');


		//#基本的
		$param_patten = [
			'#<hdsysinfo(.*?)/>#',
			'#<hdsyspage(.*?)/>#'

		];
		$translation = [
			'',
			''
		];
		$this->intelligence_FileTemplatescContent = preg_replace($param_patten, $translation, $this->intelligence_FileTemplatescContent);


		// if ($param_DIV_MEIN == 1) {

		// 	$this->intelligence_FileTemplatescContent = preg_replace_callback(
		// 		'/<hdsyscms-div(.*?)>(.*?)<\/hdsyscms-div>/is',
		// 		function ($param_matches) {

		// 			$param_array = call_my_GetDivArray($param_matches[1]);
		// 			if ($param_array['type'] == 'img') {

		// 				if (!isset($param_array['style'])) {
		// 					$param_array['style'] = '';
		// 				}
		// 				if (!isset($param_array['alt'])) {
		// 					$param_array['alt'] = '';
		// 				}
		// 				if (!isset($param_array['class'])) {
		// 					$param_array['class'] = '';
		// 				}


		// 				$param_div = call_my_array_div($param_array);

		// 				// getsysurl() .
		// 				return "<hdsyscms-div {$param_div}><img  style='{$param_array['style']}' alt='{$param_array['alt']}' class='{$param_array['class']}' name='{$param_array['id']}' src='" . "{$param_array['src']}' /></hdsyscms-div>";
		// 			} elseif ($param_array['type'] == 'val') {
		// 				return $param_matches[2];
		// 			}



		// 			return $param_matches[0];
		// 		},
		// 		$this->intelligence_FileTemplatescContent
		// 	);
		// }




		//if ($param_DIV_MEIN == 0) {
		//#基本的
		// $param_patten = [
		// 	'#<hdsysinfo(.*?)/>#'
		// ];
		// $translation = [
		// 	''
		// ];
		// $this->intelligence_FileTemplatescContent = preg_replace($param_patten, $translation, $this->intelligence_FileTemplatescContent);



		// 	$this->intelligence_FileTemplatescContent = preg_replace_callback(
		// 		'/<hdsyscms-div(.*?)>(.*?)<\/hdsyscms-div>/is',
		// 		function ($param_matches) {

		// 			$param_array = call_my_GetDivArray($param_matches[1]);


		// 			$param_type = $param_array['type'];


		// 			unset($param_array['id']);
		// 			unset($param_array['type']);
		// 			unset($param_array['name']);

		// 			$param_div = call_my_array_div($param_array);
		// 			if ($param_type == 'img') {


		// 				$param_src = $param_array['src'];
		// 				unset($param_array['src']);
		// 				$param_div = call_my_array_div($param_array);


		// 				return "<img {$param_div}  src='" . getsysurl() . "{$param_src}' />";
		// 			} else if ($param_type == 'div') {

		// 				return "<div {$param_div} >{$param_matches[2]}</div>";
		// 			}


		// 			return "{$param_matches[2]}";
		// 		},
		// 		$this->intelligence_FileTemplatescContent
		// 	);
		// }


		// $this->intelligence_FileTemplatescContent = preg_replace_callback(
		// 	'/<hdsyscms-a(.*?)>(.*?)<\/hdsyscms-a>/is',
		// 	function ($param_matches) {
		// 		$param_array = call_my_GetDivArray($param_matches[1]);
		// 		if (!isset($param_array['style'])) {
		// 			$param_array['style'] = '';
		// 		}
		// 		if (!isset($param_array['alt'])) {
		// 			$param_array['alt'] = '';
		// 		}
		// 		if (!isset($param_array['class'])) {
		// 			$param_array['class'] = '';
		// 		}

		// 		return "<a  style='{$param_array['style']}' alt='{$param_array['alt']}' class='{$param_array['class']}' name='{$param_array['id']}' href='" . "{$param_array['src']}' >{$param_matches[2]}</a>";
		// 	},
		// 	$this->intelligence_FileTemplatescContent
		// );


		// $this->intelligence_FileTemplatescContent = preg_replace_callback(
		// 	'/<hdsyscms-img(.*?)\/>/is',
		// 	function ($param_matches) {
		// 		$param_array = call_my_GetDivArray($param_matches[1]);
		// 		if (!isset($param_array['style'])) {
		// 			$param_array['style'] = '';
		// 		}
		// 		if (!isset($param_array['alt'])) {
		// 			$param_array['alt'] = '';
		// 		}
		// 		if (!isset($param_array['class'])) {
		// 			$param_array['class'] = '';
		// 		}

		// 		return "<img  style='{$param_array['style']}' alt='{$param_array['alt']}' class='{$param_array['class']}' name='{$param_array['id']}' src='" . "{$param_array['src']}' />";
		// 	},
		// 	$this->intelligence_FileTemplatescContent
		// );


		//#美化代码除去空格

		$this->intelligence_FileTemplatescContent = preg_replace("|\s*\n+|", PHP_EOL, str_replace(array("\r\n", "\r"), "\n", $this->intelligence_FileTemplatescContent));

		//删除代码首尾空
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			"/([\w\W]*\n+)/iU",
			function ($matches) {
				//print_R($matches);
				//exit;
				if (substr(trim($matches[0]), 0, 2) == '//') {
					return '';
				} else {
					return trim($matches[0]) . "\n";
				}
			},
			$this->intelligence_FileTemplatescContent
		);
	}

	public function intelligence_basic1($param_url_name)
	{

		#设置缩略图替换
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\{\$([a-zA-Z0-9_]+)\.graph\}#',
			function ($param_matches) {
				//print_R($param_matches);
				return '<?php echo GetImgesUrl($' . $param_matches[1] . '["graph"]);   ?>';
			},
			$this->intelligence_FileTemplatescContent
		);



		//print_r($param_data);






		//#基本的
		$patten = [

			'#\$([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)([\s]+|)\)#',
			'#\(\$([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\)#',
			'#\({\$([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\}\)#',
			'#\{(else if|elseif) (.*?)\}#',
			'#\{else\}#',
			'#\{\/(foreach|if)}#',
			'#\{\\^(k|v)\}#',
			'#\{foreach \$(.*?)\.(.*?) as (.*?) \}#',
			'#\{!(.*?)\}#',
			'#\{\$([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\}#',
			'#\{@(.*?)\}#',
			'#\{__STATICS__\}#',
			'#\{__DOMAIN__\}#',
			'#\{__URL__\}#',
			'#\{foreach (.*?) as \$(.*?)\}#',
			'#\{\$vo\}#',
			'#\{php (.*?)\}#',
			'#\{if (.*?)\}#',
			'#{__URI__}#',
			'#__URI__#',
			'#{__TEMPLATES__}#',

			//这里处理自定义模版的
			'#\{\$([a-zA-Z0-9_]+)\.modules\.([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\}#',
			'#\{\$([a-zA-Z0-9_]+)\.modules\.([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\.([0-9]+)\}#',
			'#\$([a-zA-Z0-9_]+)\.modules\.([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\.([0-9]+)#',
			'#\$([a-zA-Z0-9_]+)\.modules\.([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)#',



			'#{__URL_NAME__}#',
			'#__URL_NAME__#',



		];
		$translation = [
			'$\\1["\\2"])',
			'($\\1["\\2"])',
			'($\\1["\\2"])',
			'<?php } else if <hdsyscms-kuohao>\\2<hdsyscms-kuohao> { ?>',
			'<?php }else { ?>',
			'<?php } ?>',
			'<?php echo \$\\1?>',
			'<?php  foreach<hdsyscms-kuohao> \$\\1["\\2"] as \\3 </hdsyscms-kuohao>{    ?>',
			'<?php  \\1;   ?>',
			'<hdsyscms-val>\$\\1[\'\\2\']</hdsyscms-val>',
			'<?php echo \\1;   ?>',
			getsysurl().'templates/' . $this->intelligence_templates_dir . '/statics',
			getsysurl(),
			getsysurl(),
			'<?php  foreach<hdsyscms-kuohao> \\1 as $\\2 </hdsyscms-kuohao>{    ?>',
			'<?php echo \$vo   ?>',
			'<?php  \\1  ?>',
			'<?php if <hdsyscms-kuohao>\\1</hdsyscms-kuohao> { ?>',
			substr(getsysurl(), 0, -1) . $_SERVER['REQUEST_URI'],
			substr(getsysurl(), 0, -1) . $_SERVER['REQUEST_URI'],
			intelligence_get_templates_dir(),

			'<?php echo isset(\$\\1["modules"]["\\2"]["\\3"][0])?GetImgesUrl(\$\\1["modules"]["\\2"]["\\3"][0]):""; ?>',
			'<?php echo isset(\$\\1["modules"]["\\2"]["\\3"][\\4])?GetImgesUrl(\$\\1["modules"]["\\2"]["\\3"][\\4]):""; ?>',
			'$\\1["modules"]["\\2"]["\\3"]["\\4"]',
			'$\\1["modules"]["\\2"]["\\3"]',


			$param_url_name,
			$param_url_name,

		];

		$this->intelligence_FileTemplatescContent = preg_replace($patten, $translation, $this->intelligence_FileTemplatescContent);
	}


	//处理细节
	public function intelligence_basic2()
	{


		//处理php代码细节

		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#<\?php (.*?) \?>#',
			function ($param_matches) {


				//print_r($param_matches);

				$intelligence_Content = $param_matches[0];



				//echo $intelligence_Content . PHP_EOL;

				//这里容易误判，不可行
				//$intelligence_Content = call_my_str_basic($intelligence_Content);



				$intelligence_Content = preg_replace_callback(
					'/\s([a-zA-Z0-9_]+)\((.*?)\)/',
					function ($param_matches) {

						//


						//判断函数内函数就不处理
						// if (stripos($param_matches[2], '(') > 0 ) {

						// 	return $param_matches[0];
						// }

						$param_matches[2] = call_my_str_basic($param_matches[2]);
						////这里要处理下文本里豆号要处理，使用地方太多了！
						$param_matches[2] = call_my_str_replace("','", "'<hdsyscms-douhao/>'", $param_matches[2]);
						$param_matches[2] = call_my_str_replace('","', '"<hdsyscms-douhao/>"', $param_matches[2]);


						//这里处理[] 数组传递大括号豆号--------------------------------------------------------
						//$param_matches[2] = preg_replace('#<hdsyscms-val>(.*?)</hdsyscms-val>#', '{\\1}', $param_matches[2]);
						//echo  $param_matches[2] . PHP_EOL;
						$param_matches[2] = preg_replace_callback(
							'/\[((.*?)=>(.*?))\](,|$|\s+,)/i',
							function ($param_matches) {
								//echo  $param_matches[0] . PHP_EOL;



								$param_matches[0] = call_my_str_replace(',', '<hdsyscms-suzu-douhao/>', $param_matches[0]);


								$param_matches[0] =   preg_replace('#\](\s+|)<hdsyscms-suzu-douhao/>#', ']\\1,', $param_matches[0]);

								return  $param_matches[0];
							},
							$param_matches[2]
						);
						//echo  $param_matches[2] . PHP_EOL;
						//-------------------------------------------------------------------------------

						$param_ex = explode(',', $param_matches[2]);



						//print_r($param_ex);

						$param_new = '';

						$param_i = 0;
						foreach ($param_ex as $param_v) {
							$param_i++;
							$param_v = call_my_newpara(trim($param_v));

							if (stripos($param_v, '"') > -1 or stripos($param_v, '"') > -1) {

								$param_v =   preg_replace('#<hdsyscms-val>(.*?)</hdsyscms-val>#', '{\\1}', $param_v);
							}

							if (stripos($param_v, '"') == false and stripos($param_v, '"') == false) {
								$param_v =   preg_replace('#<hdsyscms-val>(.*?)</hdsyscms-val>#', '\\1', $param_v);
							}


							//$param_new .= trim($v); call_my_newpara



							//处理数组[] 参数，--------------------------------------------
							if (substr($param_v, 0, 1) == '[' and substr($param_v, -1) == ']' and $param_v != '' and $param_v != '[]') {



								$param_y_i = 0;
								$para_data = substr($param_v, 1, -1);
								$para_data_arr = explode('<hdsyscms-suzu-douhao/>', $para_data);
								$param_tmp = '';


								foreach ($para_data_arr as $param_y) {

									$param_y_i++;
									$para_data_ex = explode('=>', $param_y);
									if (substr($para_data_ex[0], 0, 1) != '"' and substr($para_data_ex[0], -1) != '"' and substr($para_data_ex[0], 0, 1) != "'" and substr($para_data_ex[0], -1) != "'") {
										$para_data_ex[0] = '"' . $para_data_ex[0] . '"';
									}

									if (substr($para_data_ex[1], 0, 1) != '"' and substr($para_data_ex[1], -1) != '"' and substr($para_data_ex[1], 0, 1) != "'" and substr($para_data_ex[1], -1) != "'") {
										$para_data_ex[1] = '"' . $para_data_ex[1] . '"';
									}

									//print_r($para_data_ex);
									$param_tmp .= $para_data_ex[0] . '=>' . $para_data_ex[1];

									if ($param_y_i < count($para_data_arr)) {
										$param_tmp .= ',';
									}
								}

								$param_v = "[{$param_tmp}]";
							}
							//------------------------------------


							$param_new .= $param_v;

							if ($param_i < count($param_ex)) {
								$param_new .= ',';
							}
						}


						//echo  $param_new . ')' . PHP_EOL ;

						if (substr($param_matches[0], 0, 1) == ' ') {
							return " {$param_matches[1]}(" . $param_new . ')';
						} else {
							return "{$param_matches[1]}(" . $param_new . ')';
						}
					},
					$intelligence_Content
				);





				return $intelligence_Content;
			},
			$this->intelligence_FileTemplatescContent
		);
	}

	//设置排序，变量放最后完成
	public function intelligence_basic3()
	{


		//return;
		$GLOBALS['replace_arr'] = array();


		//替换变量
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			DIV_HDSYSCMS_VALUE,
			function ($param_matches) {


				$param_array = call_my_GetDivArray($param_matches[0]);

				if (!isset($param_array['val'])) {
					$param_array['val'] = '';
				}

				if (isset($param_array['name']) and $param_array['name'] != '') {
					$GLOBALS['replace_arr'][] = array('name' => $param_array['name'], 'val' => $param_array['val']);
				}


				return $param_array['val'];
			},
			$this->intelligence_FileTemplatescContent
		);



		//替换变量值内容调用
		foreach ($GLOBALS['replace_arr'] as $param_v) {


			$this->intelligence_FileTemplatescContent = str_replace("{{$param_v['name']}}", $param_v['val'], 	$this->intelligence_FileTemplatescContent);
		}

		unset($GLOBALS['replace_arr']);


		//#基本的//'#<hdsyscms-kuohao>(.*?)</hdsyscms-kuohao>#', //'( \\1  )',
		$patten = [
			'#<hdsyscms-val>(.*?)</hdsyscms-val>#',
			'#<hdsyscms-douhao/>#',
			//'{\$v}',
			// '#"../upfiles/attached/image/#',
			// '#\'../upfiles/attached/image/#',
			// '#"/upfiles/attached/image/#',
			// '#\'/upfiles/attached/image/#',
		];
		$translation = [
			'<?php echo @\\1  ?>',
			',',
			//bs_lib::get_configs_value('setup', 'dbug') == 0 ? filemtime(HDSYS_DIR_SYS . 'cache/configs') : time(),
			// '"' . getsysurl() . 'upfiles/attached/image/',
			// '\'' . getsysurl() . 'upfiles/attached/image/',
			// '"' . getsysurl() . 'upfiles/attached/image/',
			// '\'' . getsysurl() . 'upfiles/attached/image/',
		];


		$this->intelligence_FileTemplatescContent = preg_replace($patten, $translation, $this->intelligence_FileTemplatescContent);

		$patten = [

			'#\{\$v\}#',
			// '#"../upfiles/attached/image/#',
			// '#\'../upfiles/attached/image/#',
			// '#"/upfiles/attached/image/#',
			// '#\'/upfiles/attached/image/#',
		];
		$translation = [

			bs_lib::get_configs_value('setup', 'dbug') == 0 ? filemtime(HDSYS_DIR_SYS . 'cache/configs') : time(),
			// '"' . getsysurl() . 'upfiles/attached/image/',
			// '\'' . getsysurl() . 'upfiles/attached/image/',
			// '"' . getsysurl() . 'upfiles/attached/image/',
			// '\'' . getsysurl() . 'upfiles/attached/image/',
		];


		$this->intelligence_FileTemplatescContent = preg_replace($patten, $translation, $this->intelligence_FileTemplatescContent);



		$this->intelligence_FileTemplatescContent = str_replace('"../upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);
		$this->intelligence_FileTemplatescContent = str_replace('\'../upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);
		$this->intelligence_FileTemplatescContent = str_replace('"/upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);
		$this->intelligence_FileTemplatescContent = str_replace('\'/upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);
		$this->intelligence_FileTemplatescContent = str_replace('|../upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);
		$this->intelligence_FileTemplatescContent = str_replace('|/upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);


		//小括号
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#<hdsyscms-kuohao>(.*?)</hdsyscms-kuohao>#',
			function ($param_matches) {
				$param_matches[1] = call_my_str_basic_kuohao($param_matches[1]);
				return "( {$param_matches[1]}  )";
			},
			$this->intelligence_FileTemplatescContent
		);

		//大括号
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#<hdsyscms-dakuohao>(.*?)</hdsyscms-dakuohao>#',
			function ($param_matches) {
				$param_matches[1] = call_my_str_basic_kuohao($param_matches[1]);
				return "{{$param_matches[1]}}";
			},
			$this->intelligence_FileTemplatescContent
		);
	}




	//#载入需要模块文件include
	public function intelligence_getinclude()
	{
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\{include:(.*?)\}#',
			function ($param_matches) {
				//print_R($param_matches);
				return $this->GetPublicFile($param_matches[1]);
			},
			$this->intelligence_FileTemplatescContent
		);


		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\<include(.*?)>#',
			function ($param_matches) {

				$param_array = call_my_GetDivArray($param_matches[1]);
				$param_file = call_my_GetArray($param_array, 'file', '');


				return $this->GetPublicFile($param_file);
			},
			$this->intelligence_FileTemplatescContent
		);
	}

	public function intelligence_getconfig()
	{
		//|#\{config:(.*?):(.*?)\}#
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\{\$config\.(.*?)\.(.*?)\}#',
			function ($param_matches) {
				return bs_lib::get_configs_value($param_matches[1], $param_matches[2]);
			},
			$this->intelligence_FileTemplatescContent
		);


		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\$config\.([a-z_]+)\.([a-z_]+)#',
			function ($param_matches) {
				//print_R($param_matches);
				return 'config("' . $param_matches[1] . '","' . $param_matches[2] . '")';
			},
			$this->intelligence_FileTemplatescContent
		);
	}
	/**
	 * @功能
	 */
	//public function intelligence_getadvertisement()
	//{
	// $this->intelligence_FileTemplatescContent = preg_replace_callback(
	// 	'#\{\$advertisement\.(.*?)\.(.*?)\}#',
	// 	function ($param_matches) {
	// 		$param_File = HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/modular/' . $param_matches[1] . '.*.modular.php';
	// 		$param_File_ARRAY = glob($param_File);
	// 		if (isset($param_File_ARRAY[0])) {
	// 			$param_arr =  include($param_File_ARRAY[0]);

	// 			if (isset($param_arr[$param_matches[2]])) {


	// 				if ($param_matches[2] == 'imges' or $param_matches[2] == 'eimges') {
	// 					return getsysurl() . 'templates/' . $this->intelligence_templates_dir . '/statics/' . $param_arr[$param_matches[2]];
	// 				} else {
	// 					return $param_arr[$param_matches[2]];
	// 				}
	// 			} else {
	// 				return '!~' . $param_matches[2] . '~!' . $param_matches[0];;
	// 			}
	// 		} else {
	// 			return '!~' . $param_matches[0];
	// 		}
	// 	},
	// 	$this->intelligence_FileTemplatescContent
	// );
	//}

	// public function navigation()
	// {
	// 	$this->intelligence_FileTemplatescContent = preg_replace_callback(
	// 		'#\{navigation (.*?) as \$(.*?) \}#',
	// 		function ($param_matches) {
	// 			$param_File_dir = $this->GetnavigationCacheArray();
	// 			return "<?php 
	// 		   \$navigation = include('{$param_File_dir}');
	// 		   foreach( \$navigation as \${$param_matches[2]}  ){ ? >";
	// 		},
	// 		$this->intelligence_FileTemplatescContent
	// 	);

	// 	$this->intelligence_FileTemplatescContent = preg_replace('#\{/navigation\}#', '<?php } ? >', $this->intelligence_FileTemplatescContent);
	// }


	//新
	public function intelligence_new_navigation()
	{


		//<模式//'/([{|<])navigation(.*?)([}|>])/i',
		$this->intelligence_FileTemplatescContent = preg_replace_callback(

			'/([{|<])navigation([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_]+|\"(.*?)\"|\'.*?\']+)(}|\s+}|>|\s+>)/i',
			function ($param_matches) {
				$param_array = call_my_GetDivArray($param_matches[0]);




				$param_File_dir = $this->GetnavigationCacheArray($param_array);
				return '<?php ' . call_my_var(call_my_GetArray($param_array, 'for', 'navigation')) . " = include('{$param_File_dir}'); \n    \$loop=0;    \n foreach( " . call_my_var(call_my_GetArray($param_array, 'for', 'navigation')) . " as " . call_my_var(call_my_GetArray($param_array, 'as', 'vo')) . "  ){ \$loop++; ?>";
			},
			$this->intelligence_FileTemplatescContent
		);



		$this->intelligence_FileTemplatescContent = call_my_str_replace(array('</navigation>', '{/navigation}'), '<?php } ?>', $this->intelligence_FileTemplatescContent);
	}



	//$param_type =英语还是中文, 中文=''
	public function str_inner($param_strdata, $param_type = 'e')
	{
		//替换处理图片
		$param_strdata = call_my_str_replace('../upfiles/', getsysurl() . 'upfiles/', $param_strdata);

		$param_sql = "SELECT * FROM `hdsys_inner`";
		$param_db_array_value = $this->intelligence_db->intelligence_query($param_sql);

		$param_while_array_list_all = array();
		while ($param_value = $this->intelligence_db->intelligence_assoc($param_db_array_value)) {

			//$param_strdata = call_my_str_replace($param_value[$param_type.'name'],"<a target='_blank' href='{$param_value[$param_type.'url']}'>{$param_value[$param_type.'name']}</a>",$param_strdata);
			$param_strdata = $this->intelligence_str_replace_once($param_value[$param_type . 'name'], "<a target='_blank' href='{$param_value[$param_type . 'url']}'>{$param_value[$param_type . 'name']}</a>", $param_strdata);
		}

		return $param_strdata;
	}

	public function intelligence_str_replace_once($param_needle, $param_replace, $param_haystack)
	{

		$param_pos = strpos($param_haystack, $param_needle);

		if ($param_pos === false) {

			return $param_haystack;
		}

		return substr_replace($param_haystack, $param_replace, $param_pos, strlen($param_needle));
	}

	//替换栏目变量 $data.id   这个要在前面执行
	public function intelligence_dataStr($data, $param_qt = 0)
	{
		$GLOBALS['dataStr'] = $data;


		//global $param_intelligence_dataStr = $data;
		//带{}的data变量
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\{\$data\.([a-zA-Z0-9_]+)\}#',
			function ($param_matches) {

				if ($param_matches[1] == 'content' and isset($GLOBALS['dataStr'][$param_matches[1]])) {
					$GLOBALS['dataStr'][$param_matches[1]] = $this->str_inner($GLOBALS['dataStr'][$param_matches[1]], '');

					//处理智能图片拼接
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('"../upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('\'../upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('"/upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('\'/upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('|../upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('|/upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);


					return '<?php echo base64_decode("' . base64_encode($GLOBALS['dataStr'][$param_matches[1]]) . '"); ?>';
				}
				if ($param_matches[1] == 'econtent' and isset($GLOBALS['dataStr'][$param_matches[1]])) {
					$GLOBALS['dataStr'][$param_matches[1]] = $this->str_inner($GLOBALS['dataStr'][$param_matches[1]], 'e');

					//处理智能图片拼接
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('"../upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('\'../upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('"/upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('\'/upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('|../upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
					$GLOBALS['dataStr'][$param_matches[1]] = str_replace('|/upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
					return '<?php echo base64_decode("' . base64_encode($GLOBALS['dataStr'][$param_matches[1]]) . '"); ?>';
				}

				$param_data  = isset($GLOBALS['dataStr'][$param_matches[1]]) ? $GLOBALS['dataStr'][$param_matches[1]] : '';
				if ($param_matches[1] == 'pid') {
					$param_data  = call_my_str_replace(',', '|', $param_data);
				}

				//判断标题seo空就显示标题名称
				if ($param_matches[1] == 'seotitle') {
					if ($param_data == '') {
						$param_data = $GLOBALS['dataStr']['name'] . ' - {$config.setup.name}';
					}
				} elseif ($param_matches[1] == 'eseotitle') {
					if ($param_data == '') {
						$param_data = $GLOBALS['dataStr']['ename'] . ' - {$config.esetup.name}';
					}
				} elseif ($param_matches[1] == 'seokeywords') {
					if ($param_data == '') {
						$param_data = '{$data.name},{$config.setup.seokeywords}';
					}
				} elseif ($param_matches[1] == 'seodescription') {
					if ($param_data == '') {
						$param_data = '{$config.setup.seodescription}';
					}
				} elseif ($param_matches[1] == 'eseokeywords') {
					if ($param_data == '') {
						$param_data = '{$data.ename},{$config.esetup.seokeywords}';
					}
				} elseif ($param_matches[1] == 'eseodescription') {
					if ($param_data == '') {
						$param_data = '{$config.esetup.seodescription}';
					}
				}


				$param_data  = call_my_str_replace(',', '<hdsyscms-douhao/>', $param_data);
				return $param_data;
			},
			$this->intelligence_FileTemplatescContent
		);


		//判断嵌套变量不要继续替换了
		if ($param_qt == 1) {
			return;
		}





		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\{\$data\.nav\.([0-9_]+)\.([a-zA-Z0-9_]+)\}#',
			function ($param_matches) {
				// if(!isset($GLOBALS['dataStr']['nav'])){
				// 	return '无栏目' ;
				// }
				return isset($GLOBALS['dataStr']['nav'][$param_matches[1]][$param_matches[2]]) ? $GLOBALS['dataStr']['nav'][$param_matches[1]][$param_matches[2]] : '';
			},
			$this->intelligence_FileTemplatescContent
		);

		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\$data\.nav\.([0-9_]+)\.([a-zA-Z0-9_]+)#',
			function ($param_matches) {
				return isset($GLOBALS['dataStr']['nav'][$param_matches[1]][$param_matches[2]]) ? $GLOBALS['dataStr']['nav'][$param_matches[1]][$param_matches[2]] : '';
			},
			$this->intelligence_FileTemplatescContent
		);

		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\$data\.([a-zA-Z0-9_]+)#',
			function ($param_matches) {

				if ($param_matches[1] == 'modules') {
					return $param_matches[0];
				}




				$param_data = isset($GLOBALS['dataStr'][$param_matches[1]]) ? $GLOBALS['dataStr'][$param_matches[1]] : '';

				if ($param_matches[1] == 'pid') {
					$param_data  = call_my_str_replace(',', '|', $param_data);
				}
				$param_data  = call_my_str_replace(',', '<hdsyscms-douhao/>', $param_data);
				return $param_data;
			},
			$this->intelligence_FileTemplatescContent
		);





		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\{\$get\.([a-zA-Z0-9_]+)\}#',
			function ($param_matches) {
				return set_get($param_matches[1]);
			},
			$this->intelligence_FileTemplatescContent
		);
		//带{}的get变量
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\$get\.([a-zA-Z0-9_]+)#',
			function ($param_matches) {
				return set_get($param_matches[1]);
			},
			$this->intelligence_FileTemplatescContent
		);

		//带{}的post变量
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\{\$post\.([a-zA-Z0-9_]+)\}#',
			function ($param_matches) {
				return set_post($param_matches[1]);
			},
			$this->intelligence_FileTemplatescContent
		);

		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\$post\.([a-zA-Z0-9_]+)#',
			function ($param_matches) {
				return set_post($param_matches[1]);
			},
			$this->intelligence_FileTemplatescContent
		);
	}

	//读取数据库部分内容显示标签
	// public function intelligence_exhibitionAs()
	// {
	//     $this->intelligence_FileTemplatescContent = preg_replace_callback(
	//         '#\{exhibition (.*?):\(array\((.*?)\) as \$(.*?)\}#',
	//         function ($param_matches) {
	//             $json = $param_matches[2];
	//             $json = call_my_str_replace('=>', ':', $json);
	//             $json = call_my_str_replace('(', '', $json);
	//             $json = call_my_str_replace(')', '', $json);
	//             $json = "{".$json."}";
	//             $jsonarr = json_decode($json, 1);


	//             $foreachname = '$'.call_my_str_replace('.', '_', $param_matches[1]);

	//             $param_File_dir = $this->intelligence_GetExhibitionMysqlArray($param_matches[1], $jsonarr);
	//             return "<?php


	//  	   {$foreachname} = include('{$param_File_dir}');
	//  	   foreach( {$foreachname} as \${$param_matches[3]}  ){ ? >" ;
	//         },
	//         $this->intelligence_FileTemplatescContent
	//     );

	//     $this->intelligence_FileTemplatescContent = preg_replace('#\{/exhibition\}#', '<?php } ? >', $this->intelligence_FileTemplatescContent);
	// }

	public function intelligence_exhibitionAs()
	{

		// $this->intelligence_FileTemplatescContent = preg_replace_callback(
		// 	'#\{exhibition(.*?)\((.*?)\)(.*?)\$([a-zA-Z0-9_]+)\}#',
		// 	function ($param_matches) {
		// 		$json = $param_matches[2];

		// 		$json = call_my_str_replace('":', '"=>', $json);
		// 		$json = call_my_str_replace('(', '', $json);
		// 		$json = call_my_str_replace(')', '', $json);
		// 		$json = call_my_str_replace('【', '(', $json);
		// 		$json = call_my_str_replace('】', ')', $json);


		// 		$json = "array(" . $json . ")";
		// 		// $jsonarr = json_decode($json, 1);
		// 		$foreachname = "\$e" . call_my_md5($json . $json);
		// 		//$param_File_dir = $this->intelligence_GetExhibitionMysqlArray($param_matches[1], $jsonarr);
		// 		$p = md5($json);
		// 		//\$savename = md5(print_r(\$a{$p},1));
		// 		return "<?php
		// 		\$a{$p} = $json ;

		// 	   {$foreachname} = include(D_Get_Exhibition_Mysql_Array(md5(print_r(\$a{$p},1)),\$a{$p}));
		// 	   foreach( {$foreachname} as \${$param_matches[4]}  ){ ? >";
		// 	},
		// 	$this->intelligence_FileTemplatescContent
		// );




		//新
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			//'#\{exhibition(.*?)\}(\s)#',
			'/([{|<])exhibition([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_]+|\"(.*?)\"|\'.*?\']+)(}|\s+}|>|\s+>)/i',
			function ($param_matches) {


				$param_array = call_my_GetDivArray($param_matches[0]);



				//print_r($param_array );



				$json = call_my_array_code($param_array);

				//echo $json;

				$foreachname = "\$e" . call_my_md5($json);

				$p = md5($json);

				return "<?php \$a{$p} = $json;  {$foreachname} = include(D_Get_Exhibition_Mysql_Array(md5(print_r(\$a{$p},1)),\$a{$p})); \n  \$loop=0;    \n foreach( {$foreachname} as " . call_my_var(call_my_GetArray($param_array, 'as', 'vo')) . "  ){  \$loop++; ?>";
			},
			$this->intelligence_FileTemplatescContent
		);


		$this->intelligence_FileTemplatescContent = call_my_str_replace(array('</exhibition>', '{/exhibition}'), '<?php } ?>', $this->intelligence_FileTemplatescContent);
	}

	//exquery
	public function intelligence_arrexhibition()
	{


		//新
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			//'#\<exquery(.*?)>#',
			'/([{|<])exquery([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_$]+|\"(.*?)\"|\'.*?\']+)(}|\s+}|>|\s+>)/i',
			function ($param_matches) {

				$param_array = call_my_GetDivArray($param_matches[0]);

				$json = call_my_array_code($param_array);


				$foreachname = call_my_var(call_my_GetArray($param_array, 'as', 'vo'));

				$p = md5($json);

				return "<?php	\$a{$p} = $json ;  {$foreachname} = include(D_Get_GetExQuery_Mysql_Array(md5(print_r(\$a{$p},1)),\$a{$p})); ?>";
			},
			$this->intelligence_FileTemplatescContent
		);
	}

	//详情列表上下页
	public function intelligence_prevnext($data)
	{

		if (!isset($data['pid'])) {
			return false;
		}



		//{$prevnext.prev.url}
		//{$prevnext.prev.name}
		//{$prevnext.next.url}
		//{$prevnext.next.name}


		if (
			stripos($this->intelligence_FileTemplatescContent, '{$prevnext.prev.url}') == false
			and stripos($this->intelligence_FileTemplatescContent, '{$prevnext.prev.name}') == false
			and stripos($this->intelligence_FileTemplatescContent, '{$prevnext.next.url}') == false
			and stripos($this->intelligence_FileTemplatescContent, '{$prevnext.next.name}') == false

			and stripos($this->intelligence_FileTemplatescContent, '{$prevnext.prev.ename}') == false

			and stripos($this->intelligence_FileTemplatescContent, '{$prevnext.next.ename}') == false

		) {
			return false;
		}



		$ColumnName = 'mysql_prevnext_' . call_my_md5($_SERVER['REQUEST_URI']);
		$param_array  = $this->GetFileArrayCodeCache($ColumnName);
		if ($param_array == false) {

			//#获取所在类目
			// $param_sql = "SELECT `id`,`template`,`static_url` FROM `hdsys_list` WHERE `id` = '{$data['pid']}' LIMIT 1 ;";
			// $param_db_array_value = $this->intelligence_db->intelligence_array($param_sql);
			// if ($param_db_array_value) {


			//#上
			$param_static_url = $data['id'] - 1;
			//`template`='{$data['template']}' and	
			$param_sql = "SELECT `id`,`name`,`ename`,`static_url` FROM `hdsys_content`  where `id` ='{$param_static_url}' limit 1 ;";
			$param_db_array_prev = $this->intelligence_db->intelligence_array($param_sql);
			if (!$param_db_array_prev) {
				$param_db_array_prev['static_url'] = '#';
				$param_db_array_prev['name'] = '';
				$param_db_array_prev['ename'] = '';
			}

			#下
			$param_static_url = $data['id'] + 1;
			//`template`='{$data['template']}' and
			$param_sql = "SELECT `id`,`name`,`ename`,`static_url` FROM `hdsys_content`  where 	 `id` = '{$param_static_url}'  limit 1 ;";
			$param_db_array_next = $this->intelligence_db->intelligence_array($param_sql);
			if (!$param_db_array_next) {
				$param_db_array_next['static_url'] = '#';
				$param_db_array_next['name'] = '';
				$param_db_array_next['ename'] = '';
			}
			// } else {




			// }

			$param_while_array_list_all = array();
			$param_while_array_list_all['prev'] = $param_db_array_prev;
			$param_while_array_list_all['next'] = $param_db_array_next;
			$this->PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
		} else {

			$param_array = include($param_array);
			$param_db_array_prev = $param_array['prev'];
			$param_db_array_next = $param_array['next'];
		}





		//{$prevnext.prev.url}
		//{$prevnext.prev.name}
		//{$prevnext.next.url}
		//{$prevnext.next.name}
		//基本的
		$patten = [

			'#\{\$prevnext\.prev\.url\}#',
			'#\{\$prevnext\.prev\.name\}#',
			'#\{\$prevnext\.next\.url\}#',
			'#\{\$prevnext\.next\.name\}#',

			'#\{\$prevnext\.prev\.ename\}#',

			'#\{\$prevnext\.next\.ename\}#',

		];
		$translation = [
			$param_db_array_prev['static_url'],
			$param_db_array_prev['name'],
			$param_db_array_next['static_url'],
			$param_db_array_next['name'],

			$param_db_array_prev['ename'],

			$param_db_array_next['ename']

		];

		$this->intelligence_FileTemplatescContent = preg_replace($patten, $translation, $this->intelligence_FileTemplatescContent);

		//#基本的
		$patten = [

			'#\$prevnext\.prev\.url#',
			'#\$prevnext\.prev\.name#',
			'#\$prevnext\.next\.url#',
			'#\$prevnext\.next\.name#',

		];
		$translation = [
			"'" . $param_db_array_prev['static_url'] . "'",
			"'" . $param_db_array_prev['name'] . "'",
			"'" . $param_db_array_next['static_url'] . "'",
			"'" . $param_db_array_next['name'] . "'"

		];

		$this->intelligence_FileTemplatescContent = preg_replace($patten, $translation, $this->intelligence_FileTemplatescContent);
	}
	//列表循环读取
	public function intelligence_columnAs($data)
	{


		$GLOBALS['data'] = $data;

		$GLOBALS['columnAs'] = 0;


		//新
		$this->intelligence_FileTemplatescContent = preg_replace_callback(

			//'#<column(.*?)>#',
			'/([{|<])column([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_]+|\"(.*?)\"|\'.*?\']+)([}|>])/i',
			function ($param_matches) {


				$param_array = call_my_GetDivArray($param_matches[0]);

				$json = call_my_array_code($param_array);




				$GLOBALS['jsonarr'] = $param_array;
				$GLOBALS['columnAs'] = 1;


				$foreachname = "\$e" . call_my_md5($json);

				$p = md5($json);

				return "<?php \$a{$p} = $json; {$foreachname} = include(D_Get_Column_Mysql_Array(md5(print_r(\$a{$p},1)),\$a{$p})); \n  \$loop=0;    \n  foreach( {$foreachname} as " . call_my_var(call_my_GetArray($param_array, 'as', 'vo')) . "  ){   \$loop++;    ?>";
			},
			$this->intelligence_FileTemplatescContent
		);


		//没有列表信息直接返回,不在执行下面继续
		if ($GLOBALS['columnAs'] == 0) {
			unset($GLOBALS['columnAs']);
			return;
		}


		$this->intelligence_FileTemplatescContent = call_my_str_replace(array('</column>', '{/column}'), '<?php } ?>', $this->intelligence_FileTemplatescContent);
	}



	//内容列表专属column 
	public function intelligence_contentAs($data, $param_url_name = '')
	{


		//print_r($data);

		//$GLOBALS['data'] = $data;
		$GLOBALS['contentAs_arr'] = array();


		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			//'/<content(.*?)=([0-9]+|[a-zA-Z0-9_]+|\"(.*?)\"|\'.*?\')([\s]+)/i',
			//'/([{|<])content([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_]+|\"(.*?)\"|\'.*?\']+)([}|>])/i',

			'#([{|<])(content|<column)([a-zA-Z0-9_\s]+=([0-9]+|[a-zA-Z0-9_$]+|\"(.*?)\"|\'.*?\'))+(}|\s+}|>|\s+>)#',

			function ($param_matches) {



				$param_array = call_my_GetDivArray($param_matches[0]);

				if (isset($param_array['pageas'])) {
					$param_array['pageas'] = call_my_str_replace('$', '', $param_array['pageas']);
				}
				//print_r($param_array);
				$json = call_my_array_code($param_array);

				// $GLOBALS['jsonarr'] = $param_array;
				// $GLOBALS['jsonarr']['table'] = 'content';


				//这里多个列表分页存变量
				$param_pageas = call_my_GetArray($param_array, 'pageas', '');

				if ($param_pageas != '') {
					$GLOBALS['contentAs_arr'][($param_pageas)] = $param_array;
				}

				// if($param_url_name==''){

				// }



				//内容的
				$foreachname = "\$e" . call_my_md5($json);
				$p = md5($json);


				//翻页的
				//$foreachname2 = "\$e" . call_my_md5($json.'2');
				$p2 = md5($json . '2');


				//[rows] => 18 [pages] => 2 [current] => 1 [prev] => 0 [next] => 2 [upper] => 1

				$param_a =  "<?php   \$a{$p2} = $json;\n  \${$param_pageas} = include(D_Get_Get_Content_Page_Mysql_Array(md5(print_r(\$a{$p2},1)),\$a{$p2})); \n  
                
                  if(isset(\${$param_pageas}['rows'])) { \${$param_pageas}_rows = \${$param_pageas}['rows']; }else { \${$param_pageas}_rows = 0; };
                   if(isset(\${$param_pageas}['pages'])){  \${$param_pageas}_pages = \${$param_pageas}['pages']; }else { \${$param_pageas}_pages = 0; };
                     if(isset(\${$param_pageas}['current'])){  \${$param_pageas}_current = \${$param_pageas}['current']; }else { \${$param_pageas}_current = 0; };
                       if(isset(\${$param_pageas}['prev'])){  \${$param_pageas}_prev = \${$param_pageas}['prev']; }else { \${$param_pageas}_prev = 0;  };
                       if(isset(\${$param_pageas}['next'])) {  \${$param_pageas}_next = \${$param_pageas}['next']; }else { \${$param_pageas}_next = 0; };
                       if(isset(\${$param_pageas}['upper'])) { \${$param_pageas}_upper = \${$param_pageas}['upper']; }else { \${$param_pageas}_upper = 0;  };
        
                         ?>";
				$param_b = "<?php	\$a{$p} = $json;  {$foreachname} = include(D_Get_Content_Mysql_Array(md5(print_r(\$a{$p},1)),\$a{$p})); \n   \$loop=0;    \n foreach( {$foreachname} as " . call_my_var(call_my_GetArray($param_array, 'as', 'vo')) . "  ){  \$loop++; ?>";


				if ($param_pageas == '') {
					return  $param_b;
				}
				return $param_a . $param_b;
			},
			$this->intelligence_FileTemplatescContent
		);


		//print_r($GLOBALS['contentAs_arr']);

		// //没有列表信息直接返回,不在执行下面继续
		// if ($GLOBALS['contentAs'] == 0) {
		// 	unset($GLOBALS['contentAs']);
		// 	return;
		// }


		//判断正则次数大0表示问题不大，尽量解决问题！
		$this->intelligence_FileTemplatescContent = str_replace(array('</content>', '{/content}'), '<?php } ?>', $this->intelligence_FileTemplatescContent);






		//这里循环翻页关联的,多个列表需要关联pageas 翻页id.
		foreach ($GLOBALS['contentAs_arr'] as $param_v) {
			$this->intelligence_page_for($param_v);
		}

		//$param_as = call_my_var(call_my_GetArray($param_array, 'as', 'vo'));


	}


	//翻页循环 这个循环标签还有个问题，后面解决 多个下需要一个标签，
	function intelligence_page_for($param_jsonarr)
	{


		$GLOBALS['pageas'] = call_my_var(call_my_GetArray($param_jsonarr, 'pageas', 'page'));
		$GLOBALS['jsonarr'] = $param_jsonarr;

		//翻页循环
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'/([{|<])page([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_]+|\"(.*?)\"|\'.*?\']+)(}|\s+}|>|\s+>)/i',
			function ($param_matches) {
				//print_R($param_matches[1]);
				// 
				//$page_array = include $this->intelligence_GetContentPageMysqlArray($param_matches[1], $GLOBALS['jsonarr']);
				// print_r($page_array);
				//$GLOBALS['page_array'] = $page_array;

				$param_array = call_my_GetDivArray($param_matches[0]);

				$param_as = call_my_var(call_my_GetArray($param_array, 'as', 'vo'));

				//print_r($param_array);


				$json = call_my_array_code($GLOBALS['jsonarr']);

				$p = md5($json . '2');

				$foreachname = "\$e" . call_my_md5($json . '2');
				$param_pageas = call_my_GetArray($GLOBALS['jsonarr'], 'pageas', '');

				return "<?php    {$GLOBALS['pageas']}s = (int)\${$param_pageas}['pages'] + 1; \n   for({$param_as}['number'] = 1; \n  {$param_as}['number'] < {$GLOBALS['pageas']}s; {$param_as}['number'] = {$param_as}['number'] + 1){ ?>";
			},
			$this->intelligence_FileTemplatescContent
		);



		$this->intelligence_FileTemplatescContent = preg_replace('#\{/page\}#', '<?php } ?>', $this->intelligence_FileTemplatescContent);

		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\{\\' . $GLOBALS['pageas'] . '\.([a-z_]+)\}#',
			function ($param_matches) {

				return  '<?php echo @' . $GLOBALS['pageas'] . "_{$param_matches[1]}" .  ' ?>';


				//return $GLOBALS['page_array'][$param_matches[1]];
			},
			$this->intelligence_FileTemplatescContent
		);

		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			'#\\' . $GLOBALS['pageas'] . '\.([a-z_]+)#',
			function ($param_matches) {

				return $GLOBALS['pageas'] . "_{$param_matches[1]}";

				//return $GLOBALS['page_array'][$param_matches[1]];
			},
			$this->intelligence_FileTemplatescContent
		);
	}


	//内容翻页规则
	public static function intelligence_GetContentPageWhere($param_arr_json)
	{

		//print_r($param_arr_json);

		$param_soso_id = (int)call_my_GetArray($param_arr_json, 'searchid', '0');
		$param_soso = call_my_GetArray($param_arr_json, 'search', '');


		$param_seltree_select_nodeId = call_my_GetArray($param_arr_json, 'pid', '');
		$param_hot = call_my_GetArray($param_arr_json, 'hot', '');




		$param_where_sql = '';


		$param_template = call_my_GetArray($param_arr_json, 'template', '');
		if ($param_template != '') {

			if ($param_where_sql != '') {
				$param_where_sql .=  " AND ";
			}


			$param_pid  = call_my_str_replace('|', ',', $param_template);
			//循环分割加'' 号
			$param_arr = explode(',', $param_pid);
			$param_sql_in = '';
			$param_i = 0;
			foreach ($param_arr as $pram_v) {
				$param_i++;
				if ($pram_v != '') {
					$param_sql_in .= "'$pram_v'";
				}

				if ($param_i < count($param_arr)) {
					$param_sql_in .= ',';
				}
			}
			$param_where_sql .= " `template` IN({$param_sql_in})  ";
		}


		if ($param_soso != '') {

			// 	//去除那些||||
			// 	$param_soso = call_my_str_replace('||', '|', $param_soso);
			//     $param_soso = call_my_str_replace('||', '|', $param_soso);
			//     $param_soso = call_my_str_replace('||', '|', $param_soso);
			//     $param_soso = call_my_str_replace('||', '|', $param_soso);
			//     $param_soso = call_my_str_replace('||', '|', $param_soso);


			// 	//判断左右如果有|去除|
			// 	if (strpos('#'.$param_soso, '#|') === 0) {
			// 		$param_soso = call_my_str_replace('#|', '', '#'.$param_soso);
			// 	}
			// 	if (strpos($param_soso, '|') === (strlen($param_soso) - 1)) {
			// 		$param_soso = call_my_str_replace('|#', '', $param_soso.'#');
			// 	}

			//    echo $param_soso ;
			$param_soso = call_my_str_replace('+', '', $param_soso);

			//<option value="1">标题</option>SELECT * FROM `hdsys_download` WHERE `name` REGEXP '北欧|2232|编辑' 
			if ($param_soso_id == 1) {

				if ($param_where_sql != '') {
					$param_where_sql .=  " AND ";
				}
				$param_where_sql .= "  ( `name`  REGEXP '{$param_soso}' or `ename`  REGEXP '{$param_soso}' )";

				// if ($param_where_sql == '') {
				// 	$param_where_sql .= "  ( `name`  REGEXP '{$param_soso}' or `ename`  REGEXP '{$param_soso}' )";
				// } else {
				// 	$param_where_sql .= " AND( `name`  REGEXP '{$param_soso}' or `ename`  REGEXP '{$param_soso}'  )";
				// }

				//<option value="2">ID</option>
			} else if ($param_soso_id == 2) {



				if ($param_where_sql != '') {
					$param_where_sql .=  " AND ";
				}
				$param_where_sql .= " `id`  = '$param_soso'  ";


				//<option value="3">链接</option>
			} else if ($param_soso_id == 3) {



				if ($param_where_sql != '') {
					$param_where_sql .=  " AND ";
				}
				$param_where_sql .= " `static_url`  REGEXP '$param_soso'  ";


				//<option value="4">内容</option>
			} else if ($param_soso_id == 4) {

				if ($param_where_sql != '') {
					$param_where_sql .=  " AND ";
				}
				$param_where_sql .= " ( `content`  REGEXP '{$param_soso}' or `econtent`  REGEXP '{$param_soso}'  )";


				// if ($param_where_sql == '') {
				// 	$param_where_sql .= " ( `content`  REGEXP '{$param_soso}' or `econtent`  REGEXP '{$param_soso}'  )";
				// } else {
				// 	$param_where_sql .= " AND( `content`  REGEXP '{$param_soso}' or `econtent`  REGEXP '{$param_soso}'  )";
				// }

				//<option value="4">SEO关键词</option>
			} else if ($param_soso_id == 5) {

				if ($param_where_sql != '') {
					$param_where_sql .=  " AND ";
				}
				$param_where_sql .= " ( `seokeywords`  REGEXP '{$param_soso}' or `eseokeywords`  REGEXP '{$param_soso}'  )";


				// if ($param_where_sql == '') {
				// 	$param_where_sql .= " ( `seokeywords`  REGEXP '{$param_soso}' or `eseokeywords`  REGEXP '{$param_soso}'  )";
				// } else {
				// 	$param_where_sql .= " AND( `seokeywords`  REGEXP '{$param_soso}' or `eseokeywords`  REGEXP '{$param_soso}'  )";
				// }

				//<option value="5">SEO描述</option>
			} else if ($param_soso_id == 6) {

				if ($param_where_sql != '') {
					$param_where_sql .=  " AND ";
				}
				$param_where_sql .= " ( `seodescription`  REGEXP '{$param_soso}' or `eseodescription`  REGEXP '{$param_soso}'  )";


				// if ($param_where_sql == '') {
				// 	$param_where_sql .= " ( `seodescription`  REGEXP '{$param_soso}' or `eseodescription`  REGEXP '{$param_soso}'  )";
				// } else {
				// 	$param_where_sql .= " AND( `seodescription`  REGEXP '{$param_soso}' or `eseodescription`  REGEXP '{$param_soso}'  )";
				// }
				//<option value="6">自定属性</option>
			} else if ($param_soso_id == 7) {

				if ($param_where_sql != '') {
					$param_where_sql .=  " AND ";
				}
				$param_where_sql .= " ( `attribute1`  REGEXP '{$param_soso}' or `eattribute1`  REGEXP '{$param_soso}' or `attribute2`  REGEXP '{$param_soso}' or `eattribute2`  REGEXP '{$param_soso}' or `attribute3`  REGEXP '{$param_soso}' or `eattribute3`  REGEXP '{$param_soso}' or `attribute4`  REGEXP '{$param_soso}' or `eattribute4`  REGEXP '{$param_soso}'  )";



				// if ($param_where_sql == '') {
				// 	$param_where_sql .= " ( `attribute1`  REGEXP '{$param_soso}' or `eattribute1`  REGEXP '{$param_soso}' or `attribute2`  REGEXP '{$param_soso}' or `eattribute2`  REGEXP '{$param_soso}' or `attribute3`  REGEXP '{$param_soso}' or `eattribute3`  REGEXP '{$param_soso}' or `attribute4`  REGEXP '{$param_soso}' or `eattribute4`  REGEXP '{$param_soso}'  )";
				// } else {
				// 	$param_where_sql .= " AND( `attribute1`  REGEXP '{$param_soso}' or `eattribute1`  REGEXP '{$param_soso}' or `attribute2`  REGEXP '{$param_soso}' or `eattribute2`  REGEXP '{$param_soso}' or `attribute3`  REGEXP '{$param_soso}' or `eattribute3`  REGEXP '{$param_soso}' or `attribute4`  REGEXP '{$param_soso}' or `eattribute4`  REGEXP '{$param_soso}'  )";
				// }
				//<option value="7">自定属性</option>//name,seokeywords,seodescription,content,econtent,attribute1,attribute2,attribute3,attribute4
			} else {

				if ($param_where_sql != '') {
					$param_where_sql .=  " AND ";
				}
				$param_where_sql .= " ( `seodescription`  REGEXP '{$param_soso}' or `eseodescription`  REGEXP '{$param_soso}' or  `seokeywords`  REGEXP '{$param_soso}' or `eseokeywords`  REGEXP '{$param_soso}' or  `content`  REGEXP '{$param_soso}' or `econtent`  REGEXP '{$param_soso}' or `name`  REGEXP '{$param_soso}' or `ename`  REGEXP '{$param_soso}' or  `attribute1`  REGEXP '{$param_soso}' or `eattribute1`  REGEXP '{$param_soso}' or `attribute2`  REGEXP '{$param_soso}' or `eattribute2`  REGEXP '{$param_soso}' or `attribute3`  REGEXP '{$param_soso}' or `eattribute3`  REGEXP '{$param_soso}' or `attribute4`  REGEXP '{$param_soso}' or `eattribute4`  REGEXP '{$param_soso}'  )";


				// if ($param_where_sql == '') {

				// 	$param_where_sql .= " ( `content`  REGEXP '{$param_soso}' or `econtent`  REGEXP '{$param_soso}' or `name`  REGEXP '{$param_soso}' or `ename`  REGEXP '{$param_soso}' or  `attribute1`  REGEXP '{$param_soso}' or `eattribute1`  REGEXP '{$param_soso}' or `attribute2`  REGEXP '{$param_soso}' or `eattribute2`  REGEXP '{$param_soso}' or `attribute3`  REGEXP '{$param_soso}' or `eattribute3`  REGEXP '{$param_soso}' or `attribute4`  REGEXP '{$param_soso}' or `eattribute4`  REGEXP '{$param_soso}'  )";
				// } else {
				// 	$param_where_sql .= " AND(  `content`  REGEXP '{$param_soso}' or `econtent`  REGEXP '{$param_soso}' or `name`  REGEXP '{$param_soso}' or `ename`  REGEXP '{$param_soso}' or `attribute1`  REGEXP '{$param_soso}' or `eattribute1`  REGEXP '{$param_soso}' or `attribute2`  REGEXP '{$param_soso}' or `eattribute2`  REGEXP '{$param_soso}' or `attribute3`  REGEXP '{$param_soso}' or `eattribute3`  REGEXP '{$param_soso}' or `attribute4`  REGEXP '{$param_soso}' or `eattribute4`  REGEXP '{$param_soso}'  )";
				// }
			}
		}



		if ($param_seltree_select_nodeId != '') {

			if ($param_where_sql != '') {
				$param_where_sql .=  " AND ";
			}
			$param_seltree_select_nodeId = call_my_str_replace(',', '|', $param_seltree_select_nodeId);

			//mysql支持in sqlite不支持只能循环
			$param_arr = explode('|', $param_seltree_select_nodeId);
			if (count($param_arr) == 1) {

				$param_tmp = "   ";
				foreach ($param_arr as $key => $value) {
					if ($value != '') {
						$param_tmp .=  " `pid` = '{$value}'   or";
					}
				}
				$param_tmp = substr($param_tmp, 0, -3);
				$param_where_sql .= " ( {$param_tmp} ) ";
			} else {
				$param_where_sql .= "   `pid`  = '{$param_seltree_select_nodeId}'  ";
			}

			//$param_seltree_select_nodeId = call_my_str_replace('|', ',', $param_seltree_select_nodeId);
			//$param_where_sql .= "   `pid`  IN('{$param_seltree_select_nodeId}')  ";


			//$param_where_sql .= "   `pid`  REGEXP '{$param_seltree_select_nodeId}'  ";
		}


		if ($param_hot > 0) {

			if ($param_where_sql != '') {
				$param_where_sql .=  " AND ";
			}
			$param_where_sql .= " `hot`  != '0'  ";
		}



		$param_sdates = call_my_GetArray($param_arr_json, 'sdates', '0');
		if ($param_sdates != '') {

			if ($param_where_sql != '') {
				$param_where_sql .=  " AND ";
			}
			$param_where_sql .= " `sdates`  = '{$param_sdates}'  ";
		}





		$param_isgraph = call_my_GetArray($param_arr_json, 'isgraph', '0');
		if ($param_isgraph != 0) {

			if ($param_where_sql != '') {
				$param_where_sql .=  " AND ";
			}
			$param_where_sql .= " `graph`  != ''  ";
		}










		$param_where = call_my_GetArray($param_arr_json, 'where', '');
		if (trim($param_where) != '') {



			$param_where_is = call_my_strtolower(call_my_str_replace(' ', '', $param_where));
			if (substr($param_where_is, 0, 2) == 'or' or substr($param_where_is, 0, 3) == 'and') {
				$param_where_sql .= "  {$param_where}  ";
			} else {
				$param_where_sql .= "  and  {$param_where}  ";
			}
		}





		//判断补充
		if ($param_where_sql != '') {
			$param_where_sql = "WHERE" . $param_where_sql;
		}

		return $param_where_sql;
	}

	//内容专用翻页
	public static function intelligence_GetContentPageMysqlArray($param_name, $param_arr_json)
	{

		$param_db = bs_lib::load_libhdsys_class("" . 'db');
		//print_r($GLOBALS);

		$param_where_sql = templates::intelligence_GetContentPageWhere($param_arr_json);
		$ColumnName = 'mysql_ColumnName_' . $param_name . '_' . md5($_SERVER['REQUEST_URI'] . $param_where_sql);
		$param_array  = templates::GetFileArrayCodeCache($ColumnName);
		if ($param_array == false or bs_lib::get_configs_value('personality', 'cache') == 1) {






			$param_rows = call_my_GetArray($param_arr_json, 'rows', '8');
			if ($param_rows == 0) {
				$param_rows = 10;
			}




			$param_sql = "SELECT count(*)as 'hangshu' FROM `hdsys_content` " . $param_where_sql;


			$param_db_array_value = $param_db->intelligence_array($param_sql);
			if (!$param_db_array_value) {
				echo '<a style="color: #CC5522;" >[模版参数错误导致sql.错误:' . $param_sql . '] ' . time() . '<a>';
				exit;
			}
			$param_tmp_rows = (int)$param_db_array_value['hangshu'];

			//条数
			$param_while_array_list_all['rows'] = $param_tmp_rows;

			//页数
			$param_while_array_list_all['pages'] = ceil($param_tmp_rows / $param_rows);

			if (set_get('page') == 0 or set_get('page') == '') {
				$param_while_array_list_all['current'] = 1;


				$param_while_array_list_all['prev'] = 1;
				$param_while_array_list_all['next'] = 1;

				if ($param_while_array_list_all['pages'] > 1) {
					$param_while_array_list_all['next'] = 2;
				}
			} else {
				$param_while_array_list_all['current'] = set_get('page');


				$param_while_array_list_all['prev'] = $param_while_array_list_all['current'] - 1;
				$param_while_array_list_all['next'] = $param_while_array_list_all['current'] + 1;


				if ($param_while_array_list_all['prev'] <= 0) {
					$param_while_array_list_all['upper'] = 1;
				}

				if ($param_while_array_list_all['next'] > $param_while_array_list_all['pages']) {
					$param_while_array_list_all['next'] = $param_while_array_list_all['pages'];
				}
			}


			return templates::PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
		} else {
			return $param_array;
		}
	}

	//翻页
	// public static function GetColumnPageMysqlArray($param_name, $param_arr_json)
	// {


	// 	$searchid = set_get('searchid'); 
	// 	//$get.searchid;
	// 	$search = set_get('search'); 
	// 	//$get.searchid;
	// 	$page = (int)set_get('page'); 
	// 	//$get.searchid;

	// 	$rows = $param_arr_json['rows'];
	// 	if ($rows == 0) {
	// 		$rows = 10;
	// 	}
	// 	//$ColumnName = 'mysql_ColumnName_Page_'.$param_name.'_'.md5($searchid.$search.$param_arr_json['where']).'_'.$page;
	// 	$ColumnName = 'mysql_ColumnName_' . $param_name . '_' . md5($_SERVER['REQUEST_URI']);
	// 	$param_array  = $this->GetFileArrayCodeCache($ColumnName);
	// 	if ($param_array == false or bs_lib::get_configs_value('personality', 'cache') == 1) {


	// 		$param_arr_json['where'] = call_my_str_replace('WHERE', ' ', $param_arr_json['where']);
	// 		if (trim($param_arr_json['where']) == '') {
	// 			$param_WHERE = " ";
	// 		} else {
	// 			$param_WHERE = " WHERE {$param_arr_json['where']} ";
	// 		}

	// 		$page_gegin = $page * $rows;

	// 		$param_while_array_list_all = array();
	// 		//判断表是否存在
	// 		if (!$this->intelligence_db->intelligence_is_table('hdsys_' . $param_arr_json['table'])) {
	// 			return $this->PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
	// 		}




	// 		$param_sql = "SELECT count(*)as 'hangshu' FROM `hdsys_{$param_arr_json['table']}` " . $param_WHERE;


	// 		$param_db_array_value = $this->intelligence_db->intelligence_array($param_sql);
	// 		if (!$param_db_array_value) {
	// 			echo '<a style="color: #CC5522;" >[模版参数错误导致sql.错误:' . $param_sql . '] ' . time() . '<a>';
	// 			exit;
	// 		}
	// 		$param_tmp_rows = (int)$param_db_array_value['hangshu'];

	// 		$param_while_array_list_all['rows'] = $param_tmp_rows;
	// 		$param_while_array_list_all['pages'] = ceil($param_tmp_rows / $rows);

	// 		if (set_get('page') == 0 or set_get('page') == '') {
	// 			$param_while_array_list_all['current'] = 1;
	// 		} else {
	// 			$param_while_array_list_all['current'] = set_get('page');
	// 		}




	// 		return $this->PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
	// 	} else {
	// 		return $param_array;
	// 	}
	// }

	//获取栏目列表的
	public static function intelligence_GetColumnMysqlArray($param_name, $param_arr_json)
	{


		$param_db = bs_lib::load_libhdsys_class("" . 'db');

		$searchid = set_get('searchid');
		//$get.searchid;
		$search = set_get('search');
		//$get.searchid;
		$page = (int)set_get('page');
		//$get.searchid;
		$param_log = (int)set_get('dbuglog');
		//$get.searchid;
		if ($page > 0) {
			$param_db_ID = $page - 1;
			//防止注入
		} else {
			$param_db_ID = 0;
			$page = 1;
		}


		$rows = $param_arr_json['rows'];
		if ($rows == 0) {
			$rows = 10;
		}
		$page_gegin = $param_db_ID * $rows;

		//$ColumnName = 'mysql_ColumnName_'.$param_name.'_'.md5($searchid.$search.$param_arr_json['where']).'_'.$page;
		// echo $_SERVER['PATH_INFO'];

		$ColumnName = 'mysql_ColumnName_' . $param_name . '_' . md5($_SERVER['REQUEST_URI']);

		$param_array  = templates::GetFileArrayCodeCache($ColumnName);
		if ($param_array == false or bs_lib::get_configs_value('personality', 'cache') == 1) {

			/* 	print_r($param_arr_json); */


			if (trim($param_arr_json['where']) == '') {
				$param_WHERE = " ";
			} else {
				$param_WHERE = " WHERE {$param_arr_json['where']} ";
			}



			//这里表示顶级栏目，把下级同属性列出来 
			$param_in_sql = ' ';
			$param_namearraylist = array();

			//搜索不需要走这里直接搜索全部就可以

			//2021 12.9改强制分类
			if (isset($GLOBALS['data']['pid']) and $search == '') {
				if ($GLOBALS['data']['pid'] == 0) {



					// print_R($GLOBALS['data']);Current classification


					/* and template='{$GLOBALS['data']['template']}' */

					/* 读取全部分类 */
					$param_sql = "SELECT * FROM `hdsys_list` WHERE  pid='{$GLOBALS['data']['id']}'  ";
					if ($param_log == 1) {
						echo "<!" . "--$param_sql--" . ">";
					}
					$param_db_array_value = $param_db->intelligence_query($param_sql);
					$param_while_array_list_all = '';
					while ($param_value = $param_db->intelligence_assoc($param_db_array_value)) {

						//$param_namearraylist[$param_value['id']]=array('listname'=>$param_value['name'],'elistname'=>$param_value['ename']);
						$param_while_array_list_all .= $param_value['id'] . ',';
					}


					if ($param_while_array_list_all != '') {
						$param_in = $param_while_array_list_all . '-1';


						if ($param_WHERE == '') {
							$param_in_sql =  " WHERE pid in($param_in)";
						} else {
							//这个or and 有正义需要加参数判断



							//是否限定当前分类下搜索或者条件使用 current=1 只在当前大目录下搜索
							if (isset($param_arr_json['current'])) {
								$param_in_sql =  " AND pid in($param_in)";
							} else {
								$param_in_sql =  " or pid in($param_in)";
							}
						}
					}
				}
			}

			//获取所有分类
			$param_namearraylist = include(templates::intelligence_ClassificationlArray('all', -1));



			$param_while_array_list_all = array();
			//判断表是否存在
			if (!$param_db->intelligence_is_table('hdsys_' . $param_arr_json['table'])) {
				return templates::PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
			}


			if (isset($param_arr_json['by'])) {
				if ($param_arr_json['by'] == '') {
					$param_arr_json['by'] = 'sort';
				}
			} else {
				$param_arr_json['by'] = 'sort';
			}

			$GLOBALS['jsonarr']['where'] = "{$param_WHERE} {$param_in_sql}";
			$param_sql = "SELECT * FROM `hdsys_{$param_arr_json['table']}` {$param_WHERE} {$param_in_sql} ORDER BY `{$param_arr_json['by']}` {$param_arr_json['sort']}  LIMIT {$page_gegin},{$rows}";

			if ($param_log == 1) {
				echo "<!" . "--$param_sql--" . ">";
			}


			$param_db_array_value = $param_db->intelligence_query($param_sql);
			if (!$param_db_array_value) {
				echo '<a style="color: #CC5522;" >[模版参数错误导致.sql错误:' . $param_sql . '] ' . time() . '<a>';
				exit;
			}

			$param_i = 0;
			while ($param_value = $param_db->intelligence_assoc($param_db_array_value)) {
				$param_i++;




				//分类
				$param_pid_arr = explode(',', $param_value['pid']);
				$param_pid_obj = array();
				krsort($param_pid_arr);
				foreach ($param_pid_arr as $param_v) {
					if (isset($param_namearraylist[$param_v])) {
						$param_namearraylist[$param_v]['id'] = $param_v;
						//$param_namearraylist[$param_v]['pid'] = $param_v;
						$param_pid_obj[] = $param_namearraylist[$param_v];
					}
				}
				$param_value['nav'] = $param_pid_obj;


				//没有分类
				if (!isset($param_value['nav'][0])) {
					$param_value['nav'][0] = array('elistname' => 'No List', 'listname' => '未分类', 'static_url' => '', 'pid' => '');

					// $param_value['elistname'] = 'No List';
					// $param_value['listname'] = '未分类';
					// $param_value['liststatic_url'] = '#';
					// $param_value['pid'] = '';
				}




				// if (isset($param_namearraylist[$param_value['pid']])) {
				// 	$param_value['listname'] = $param_namearraylist[$param_value['pid']]['listname'];
				// 	$param_value['elistname'] = $param_namearraylist[$param_value['pid']]['elistname'];
				// 	$param_value['liststatic_url'] = $param_namearraylist[$param_value['pid']]['static_url'];
				// } else {
				// 	$param_value['elistname'] = 'No List';
				// 	$param_value['listname'] = '未分类';
				// 	$param_value['liststatic_url'] = '#';
				// }

				$param_value['i'] = $param_i;
				$param_while_array_list_all[] = $param_value;
			}

			return templates::PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
		} else {
			return $param_array;
		}
	}



	//template="product" search="" searchid='' pid="17,18,19" sdates="" isgraph='0'  sort=ASC  begin=0  rows=8  where=" graph!='' "   as
	//列表循环
	public static function intelligence_GetContentMysqlArray($param_name, $param_arr_json)
	{

		$param_db = bs_lib::load_libhdsys_class("" . 'db');



		//这个是处理条件参数的
		$param_where_sql = templates::intelligence_GetContentPageWhere($param_arr_json);



		//判断是否读缓存
		$ColumnName = 'mysql_ContenName_' . $param_name . '_' . md5($_SERVER['REQUEST_URI'] . $param_where_sql);
		$param_array  = templates::GetFileArrayCodeCache($ColumnName);
		if ($param_array == false or bs_lib::get_configs_value('personality', 'cache') == 1) {




			$param_page = call_my_GetArray($param_arr_json, 'page', '0');
			$param_log = (int)set_get('dbuglog');
			//$get.searchid;
			if ($param_page > 0) {
				$param_db_ID = $param_page - 1;
				//防止注入
			} else {
				$param_db_ID = 0;
			}



			$param_begin = call_my_GetArray($param_arr_json, 'begin', '0');
			$param_rows = call_my_GetArray($param_arr_json, 'rows', '8');
			if ($param_rows == 0) {
				$param_rows = 10;
			}
			$page_gegin = $param_begin + $param_db_ID * $param_rows;


			$param_namearraylist = array();
			//获取所有分类
			$param_namearraylist = include(templates::intelligence_ClassificationlArray('all', -1));
			//搜索不需要走这里直接搜索全部就可以


			$param_while_array_list_all = array();

			$param_by = call_my_GetArray($param_arr_json, 'by', 'add_time');

			$param_sort = call_my_GetArray($param_arr_json, 'sort', 'DESC');


			//$GLOBALS['jsonarr']['page_where_sql'] = $param_where_sql;
			//"{$param_WHERE} {$param_in_sql}";

			// 	//去除那些||||
			// 	$param_soso = call_my_str_replace('||', '|', $param_soso);
			//     $param_soso = call_my_str_replace('||', '|', $param_soso);
			//     $param_soso = call_my_str_replace('||', '|', $param_soso);
			//     $param_soso = call_my_str_replace('||', '|', $param_soso);
			//     $param_soso = call_my_str_replace('||', '|', $param_soso);


			// 	//判断左右如果有|去除|
			// 	if (strpos('#'.$param_soso, '#|') === 0) {
			// 		$param_soso = call_my_str_replace('#|', '', '#'.$param_soso);
			// 	}
			// 	if (strpos($param_soso, '|') === (strlen($param_soso) - 1)) {
			// 		$param_soso = call_my_str_replace('|#', '', $param_soso.'#');
			// 	}



			$param_sql = "SELECT * FROM `hdsys_content` {$param_where_sql} ORDER BY `{$param_by}` {$param_sort}  LIMIT {$page_gegin},{$param_rows}";

			if ($param_log == 1) {
				echo "<!" . "--$param_sql--" . ">";
			}


			$param_db_array_value = $param_db->intelligence_query($param_sql);
			if (!$param_db_array_value) {
				echo '<a style="color: #CC5522;" >[模版参数错误导致.sql错误:' . $param_sql . '] ' . time() . '<a>';
				exit;
			}

			$param_i = 0;
			while ($param_value = $param_db->intelligence_assoc($param_db_array_value)) {
				$param_i++;


				$param_value['sql'] = $param_sql;



				if (isset($param_namearraylist[$param_value['pid']])) {
					$param_value['listname'] = $param_namearraylist[$param_value['pid']]['listname'];
					$param_value['elistname'] = $param_namearraylist[$param_value['pid']]['elistname'];
					$param_value['liststatic_url'] = $param_namearraylist[$param_value['pid']]['static_url'];
				} else {
					$param_value['elistname'] = 'No List';
					$param_value['listname'] = '未分类';
					$param_value['liststatic_url'] = '#';
				}

				$param_value['modules'] = json_decode($param_value['modules'], 1);
				$param_value['emodules'] = json_decode($param_value['emodules'], 1);

				$param_value['i'] = $param_i;
				$param_while_array_list_all[] = $param_value;
			}

			return templates::PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
		} else {
			return $param_array;
		}
	}




	public static function intelligence_ClassificationlArray($param_name, $param_arr_json)
	{

		$param_array  = templates::GetFileArrayCodeCache('mysql_Classi_ficati_onlArray_' . $param_name);
		if ($param_array == false or bs_lib::get_configs_value('personality', 'cache') == 1) {
			$param_db = bs_lib::load_libhdsys_class("" . 'db');

			/* if($param_arr_json==-1){ 
				
			 }else{
				$param_sql = "SELECT * FROM `hdsys_list` WHERE  pid='{$param_arr_json}'  ";
			} */

			$param_sql = "SELECT * FROM `hdsys_list`   ";


			/* if($param_log==1){
	        	echo "<!"."--$param_sql--".">";
	        } */
			$param_db_array_value = $param_db->intelligence_query($param_sql);
			$param_while_array_list_all = '';
			while ($param_value = $param_db->intelligence_assoc($param_db_array_value)) {

				$param_namearraylist[$param_value['id']] = array('listname' => $param_value['name'], 'elistname' => $param_value['ename'], 'name' => $param_value['name'], 'ename' => $param_value['ename'], 'static_url' => $param_value['static_url'], 'pid' => $param_value['pid']);
				//$param_while_array_list_all.=$param_value['id'].',';
			}




			/* if($param_while_array_list_all!=''){
	               $param_in = $param_while_array_list_all.'-1';
	        
	        } */


			return templates::PushFileArrayCodeCache('mysql_Classi_ficati_onlArray_' . $param_name, $param_namearraylist);
		} else {
			return $param_array;
		}
	}

	//智能广告模块标签
	public function intelligence_advertisementAs()
	{
		$this->intelligence_FileTemplatescContent = preg_replace_callback(
			//'#\{advertisement (.*?) as \$(.*?)\}#',
			'#([{|<])advertisement([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_]+|\"(.*?)\"|\'.*?\'])+(}|\s+}|>|\s+>)#',
			function ($param_matches) {

				$param_array = call_my_GetDivArray($param_matches[0]);

				$param_filename = call_my_GetArray($param_array, 'filename', '');



				$param_File_dir = $this->intelligence_getadvertisementArray($param_filename);

				$param_for_val = call_my_var('a' . call_my_var(time()));

				$param_as = call_my_var(call_my_GetArray($param_array, 'as', 'vo'));

				return "<?php   {$param_for_val} = include('{$param_File_dir}');  \n   \$loop=0;    \n foreach( {$param_for_val} as {$param_as}  ){ \$loop++; ?>";
			},
			$this->intelligence_FileTemplatescContent
		);

		$this->intelligence_FileTemplatescContent = preg_replace('#\{/advertisement\}#', '<?php } ?>', $this->intelligence_FileTemplatescContent);
	}

	//数据库缓存
	public static function intelligence_GetExhibitionMysqlArray($param_name, $param_arr_json)
	{


		//echo 111111111;
		$param_array  = templates::GetFileArrayCodeCache('mysql_Exhibition_' . $param_name);
		if ($param_array == false or bs_lib::get_configs_value('personality', 'cache') == 1) {


			//echo 3333333;

			$param_arr_json['where'] = call_my_GetArray($param_arr_json, 'where', '');
			$param_arr_json['by'] = call_my_GetArray($param_arr_json, 'by', 'sort');
			$param_arr_json['sort'] = call_my_GetArray($param_arr_json, 'sort', 'desc');
			$param_arr_json['begin'] = call_my_GetArray($param_arr_json, 'begin', '0');
			$param_arr_json['rows'] = call_my_GetArray($param_arr_json, 'rows', '10');
			$param_arr_json['table'] = call_my_GetArray($param_arr_json, 'table', '');


			$param_db = bs_lib::load_libhdsys_class("" . 'db');

			if (trim($param_arr_json['where']) == '') {
				$param_WHERE = " ";
			} else {
				$param_WHERE = " WHERE {$param_arr_json['where']} ";
			}

			if (isset($param_arr_json['by'])) {
				if ($param_arr_json['by'] == '') {
					$param_arr_json['by'] = 'sort';
				}
			} else {
				$param_arr_json['by'] = 'sort';
			}

			$random_sql = "";
			if (isset($param_arr_json['random'])) {
				if ($param_arr_json['random'] == false) {
					$random_sql = "";
				} else {
					$random_sql = " ORDER BY RAND() ";
				}
			} else {
				$random_sql = "";
			}

			if ($param_arr_json['rows'] == 0) {
				$param_arr_json['rows'] = 8;
			}
			$param_while_array_list_all = array();
			//判断表是否存在
			//echo 'hdsys_' . $param_arr_json['table'];
			if (!$param_db->intelligence_is_table('hdsys_' . $param_arr_json['table'])) {

				echo '<a style="color: #CC5522;" >[exhibition标签 table参数数据表不存在~错误:' . $param_arr_json['table'] . '] ' . call_my_time() . '<a>';
				return templates::PushFileArrayCodeCache('mysql_Exhibition_' . $param_name, $param_while_array_list_all);
			}


			if ($random_sql == '') {
				$param_sql = "SELECT * FROM `hdsys_{$param_arr_json['table']}`    {$param_WHERE}    ORDER BY `{$param_arr_json['by']}` {$param_arr_json['sort']}  LIMIT {$param_arr_json['begin']},{$param_arr_json['rows']}";
			} else {
				$param_sql = "SELECT * FROM `hdsys_{$param_arr_json['table']}`    {$param_WHERE}  {$random_sql}    LIMIT {$param_arr_json['rows']}";
			}

			//echo $param_sql;


			$param_db_array_value = $param_db->intelligence_query($param_sql);
			if (!$param_db_array_value) {
				echo '<a style="color: #CC5522;" >[模版参数错误导致sql~错误:' . $param_sql . '] ' . call_my_time() . '<a>';
				exit;
			}

			//获取所有分类
			$param_namearraylist = include(templates::intelligence_ClassificationlArray('all', -1));


			$param_i = 0;
			while ($param_value = $param_db->intelligence_assoc($param_db_array_value)) {
				$param_i++;
				$param_value['i'] = $param_i;

				if (isset($param_value['pid'])) {
					if (isset($param_namearraylist[$param_value['pid']])) {
						$param_value['listname'] = $param_namearraylist[$param_value['pid']]['listname'];
						$param_value['elistname'] = $param_namearraylist[$param_value['pid']]['elistname'];
						$param_value['liststatic_url'] = $param_namearraylist[$param_value['pid']]['static_url'];
					} else {
						$param_value['elistname'] = 'No List';
						$param_value['listname'] = '未分类';
						$param_value['liststatic_url'] = '#';
					}
				}


				$param_while_array_list_all[] = $param_value;
			}




			return templates::PushFileArrayCodeCache('mysql_Exhibition_' . $param_name, $param_while_array_list_all);
		} else {

			return $param_array;
		}
	}

	public static function intelligence_GetExQueryMysqlArray($param_name, $param_arr_json)
	{

		$param_array  = templates::GetFileArrayCodeCache('mysql_GetExQuery_' . $param_name);
		if ($param_array == false) {
			$param_db = bs_lib::load_libhdsys_class("" . 'db');


			if (!isset($param_arr_json['where']) or trim($param_arr_json['where']) == '') {
				$param_WHERE = " ";
			} else {
				$param_WHERE = " WHERE {$param_arr_json['where']} ";
			}

			if (isset($param_arr_json['by'])) {
				if ($param_arr_json['by'] == '') {
					$param_arr_json['by'] = 'sort';
				}
			} else {
				$param_arr_json['by'] = 'sort';
			}

			$random_sql = "";
			if (isset($param_arr_json['random'])) {
				if ($param_arr_json['random'] == false) {
					$random_sql = "";
				} else {
					$random_sql = " ORDER BY RAND() ";
				}
			} else {
				$random_sql = "";
			}


			$param_arr_json['rows'] = call_my_GetArray($param_arr_json, 'rows', '1');
			if ($param_arr_json['rows'] == 0) {
				$param_arr_json['rows'] = 1;
			}


			if (!isset($param_arr_json['table'])) {
				$param_arr_json['table'] = '';
			}


			$param_while_array_list_all = array();
			//判断表是否存在
			if (!$param_db->intelligence_is_table('hdsys_' . $param_arr_json['table'])) {
				echo '<a style="color: #CC5522;" >[exquery标签 table参数数据表不存在~错误:' . $param_arr_json['table'] . '] ' . call_my_time() . '<a>';
				return templates::PushFileArrayCodeCache('mysql_GetExQuery_' . $param_name, $param_while_array_list_all);
			}


			if ($random_sql == '') {
				$param_sql = "SELECT * FROM `hdsys_{$param_arr_json['table']}`    {$param_WHERE}    ORDER BY `{$param_arr_json['by']}` {$param_arr_json['sort']}  LIMIT {$param_arr_json['begin']},{$param_arr_json['rows']}";
			} else {
				$param_sql = "SELECT * FROM `hdsys_{$param_arr_json['table']}`    {$param_WHERE}  {$random_sql}    LIMIT {$param_arr_json['rows']}";
			}

			//echo $param_tmp;

			$param_db_array_value = $param_db->intelligence_query($param_sql);
			if (!$param_db_array_value) {
				echo '<a style="color: #CC5522;" >[模版参数错误导致sql~错误:' . $param_sql . '] ' . call_my_time() . '<a>';
				exit;
			}

			$param_i = 0;
			while ($param_value = $param_db->intelligence_assoc($param_db_array_value)) {
				$param_i++;
				$param_value['i'] = $param_i;
				$param_while_array_list_all[] = $param_value;
			}

			if ($param_arr_json['rows'] == 1) {
				if (isset($param_while_array_list_all[0])) {
					$param_while_array_list_all = $param_while_array_list_all[0];
				}
			}


			return templates::PushFileArrayCodeCache('mysql_GetExQuery_' . $param_name, $param_while_array_list_all);
		} else {
			return $param_array;
		}
	}
	//智能广告数据处理
	public function intelligence_getadvertisementArray($param_name)
	{
		$param_array  = $this->GetFileArrayCodeCache('Advertisement_' . $param_name);
		if ($param_array == false) {
			$param_File = HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/modular/' . $param_name . '.*.modular.php';
			$param_File_ARRAY = glob($param_File);
			$param_while_array_list_all = array();
			foreach ($param_File_ARRAY as $param_filename) {
				if (file_exists($param_filename)) {
					$param_arr = include($param_filename);
					if (isset($param_arr['name']) && isset($param_arr['code'])) {





						$param_val = $param_arr['imges'];
						$param_val = str_replace('{__URL__}', getsysurl(), $param_val);
						$param_arr['imges'] = str_replace('{__TEMPLATES__}',  intelligence_get_templates_dir(), $param_val);

						$param_val = $param_arr['eimges'];
						$param_val = str_replace('{__URL__}', getsysurl(), $param_val);
						$param_arr['eimges'] = str_replace('{__TEMPLATES__}',  intelligence_get_templates_dir(), $param_val);


						$param_while_array_list_all[] = $param_arr;
					}
				}
			}
			return $this->PushFileArrayCodeCache('Advertisement_' . $param_name, $param_while_array_list_all);
		} else {
			return $param_array;
		}
	}

	//获取栏目列表循环
	public function GetListArray($param_pid)
	{
		/*开始枚举*/

		$param_sql = "SELECT * FROM`hdsys_list`WHERE sdates = 0 and `pid` = '{$param_pid}'   ORDER BY`sort`ASC LIMIT 1000";

		$param_db_array_value = $this->intelligence_db->intelligence_query($param_sql);
		$param_while_array_list_all = array();


		while ($param_value = $this->intelligence_db->intelligence_assoc($param_db_array_value)) {
			//print_r($param_value);
			$param_children = $this->GetListArray($param_value['id']);

			if (count($param_children) > 0) {
				$param_value['data'] = $param_children;
			}


			// if ($param_value['template'] == 'jmp' and $param_value['url'] == '') $param_value['url'] = getsysurl();
			// if ($param_value['template'] == 'jmp' and $param_value['eurl'] == '') $param_value['eurl'] = getsysurl();

			$param_while_array_list_all[] = $param_value;
		}


		return $param_while_array_list_all;
	}

	//PID
	public function intelligence_GetListArrayPid($param_pid, $pram_name)
	{



		$param_pid  = call_my_str_replace('|', ',', $param_pid);
		//循环分割加'' 号
		$param_arr = explode(',', $param_pid);
		$param_sql_in = '';
		$param_i = 0;
		foreach ($param_arr as $pram_v) {
			$param_i++;
			if ($pram_v != '') {
				$param_sql_in .= "'$pram_v'";
			}

			if ($param_i < count($param_arr)) {
				$param_sql_in .= ',';
			}
		}



		//不等于0，就是读取当前栏目同列表其他列表，如果点击顶级栏目显示栏目下所有，如果点击同栏目就是取pid的

		$param_sql = "SELECT * FROM`hdsys_list`WHERE `sdates` = 0 AND `{$pram_name}` IN({$param_sql_in}) ORDER BY`sort`ASC LIMIT 1000";



		$param_db_array_value = $this->intelligence_db->intelligence_query($param_sql);

		$param_while_array_list_all = array();

		while ($param_value = $this->intelligence_db->intelligence_assoc($param_db_array_value)) {
			// $param_while_array_list_all[]=$param_value;


			$param_children = $this->GetListArray($param_value['id']);

			if (count($param_children) > 0) {
				$param_value['data'] = $param_children;
			}
			// if ($param_value['template'] == 'jmp' and $param_value['url'] == '') $param_value['url'] = getsysurl();
			// if ($param_value['template'] == 'jmp' and $param_value['eurl'] == '') $param_value['eurl'] = getsysurl();


			$param_while_array_list_all[] = $param_value;
		}



		return $param_while_array_list_all;
	}


	//获取部分的栏目
	public function intelligence_GetListArrayParent($param_pid)
	{

		$param_pid  = call_my_str_replace('|', ',', $param_pid);
		//循环分割加'' 号
		$param_arr = explode(',', $param_pid);
		$param_sql_in = '';
		$param_i = 0;
		foreach ($param_arr as $pram_v) {
			$param_i++;
			if ($pram_v != '') {
				$param_sql_in .= "'$pram_v'";
			}

			if ($param_i < count($param_arr)) {
				$param_sql_in .= ',';
			}
		}


		$param_sql = "SELECT id,pid FROM`hdsys_list` WHERE  `id`in ({$param_sql_in})  LIMIT 1";
		$param_db_array = $this->intelligence_db->intelligence_array($param_sql);

		if (!$param_db_array) {
			$param_db_array['pid'] = 0;
		}


		//不等于0，就是读取当前栏目同列表其他列表，如果点击顶级栏目显示栏目下所有，如果点击同栏目就是取pid的 id,pid,static_url,name,ename,url,eurl,template
		$param_sql = "SELECT * FROM`hdsys_list`WHERE   sdates = 0 and(pid='{$param_pid}'   or pid ='{$param_db_array['pid']}' and pid != 0 ) ORDER BY`sort`ASC LIMIT 1000";


		$param_db_array_value = $this->intelligence_db->intelligence_query($param_sql);
		$param_while_array_list_all = array();
		while ($param_value = $this->intelligence_db->intelligence_assoc($param_db_array_value)) {
			// $param_while_array_list_all[]=$param_value;


			$param_children = $this->GetListArray($param_value['id']);

			if (count($param_children) > 0) {
				$param_value['data'] = $param_children;
			}

			// if ($param_value['template'] == 'jmp' and $param_value['url'] == '') $param_value['url'] = getsysurl();
			// if ($param_value['template'] == 'jmp' and $param_value['eurl'] == '') $param_value['eurl'] = getsysurl();

			$param_while_array_list_all[] = $param_value;
		}
		//print_r($param_while_array_list_all);
		return $param_while_array_list_all;
	}



	//把导航栏信息缓存起来
	public function GetnavigationCacheArray($param_array)
	{



		$param_parent = call_my_GetArray($param_array, 'parent', '0');
		//传递栏目id，获取父栏目整个栏目列表
		$param_pid = call_my_GetArray($param_array, 'pid', '');

		$param_id = call_my_GetArray($param_array, 'id', '');
		//详情页列表，获取这个文章所有分配栏目
		$param_template = call_my_GetArray($param_array, 'template', '');
		//template=显示同模版，如单页page,news 等参数

		// echo "param_parent=$param_parent" . PHP_EOL;
		// echo "param_pid=$param_pid" . PHP_EOL;
		// echo "param_id=$param_id" . PHP_EOL;
		// echo "param_template=$param_template" . PHP_EOL;


		$param_key = 'mysql_navigation_' . md5($param_parent . $param_pid . $param_template);
		$param_array  = $this->GetFileArrayCodeCache($param_key);
		if ($param_array == false) {

			$param_while_array_list_all = array();






			if ($param_template != '' and count($param_while_array_list_all) == 0) {
				//echo 1111 . PHP_EOL;
				$param_while_array_list_all = $this->intelligence_GetListArrayPid($param_template, 'template');
			}


			if ($param_id != '' and count($param_while_array_list_all) == 0) {
				//echo 2222 . PHP_EOL;
				$param_while_array_list_all = $this->intelligence_GetListArrayPid($param_pid, 'id');
			}


			if ($param_pid != '' and count($param_while_array_list_all) == 0) {
				//echo 3333 . PHP_EOL;
				$param_while_array_list_all = $this->intelligence_GetListArrayPid($param_pid, 'pid');
				//echo count($param_while_array_list_all);
			}


			if ($param_parent != '' and count($param_while_array_list_all) == 0) {
				//echo 4444 . PHP_EOL;
				$param_while_array_list_all = $this->intelligence_GetListArrayParent($param_parent);
			}

			if (count($param_while_array_list_all) == 0) {
				//echo 5555 . PHP_EOL;
				$param_while_array_list_all = $this->GetListArray(0);
			}



			return $this->PushFileArrayCodeCache($param_key, $param_while_array_list_all);
		} else {
			return $param_array;
		}
	}




	//通用功能写入缓存
	public static function PushFileArrayCodeCache($param_filename, $param_array)
	{

		//print_R($param_array); echo

		//         $json = json_encode($param_array, JSON_UNESCAPED_UNICODE);
		//         $param_code_array_php = '<?php
		// $json = <<<Eof
		// '.$json.PHP_EOL.'Eof;
		// return  json_decode($json,true); ? >';

		$param_code_array_php = ArrayToCodeFile($param_array);
		$param_File = HDSYS_DIR_SYS . 'cache/configs/' . $param_filename . '.config.php';
		$param_tmp = file_put_contents($param_File, $param_code_array_php);
		return $param_File;
		//return include($param_File);
	}
	//通用功能读出缓存
	public static function GetFileArrayCodeCache($param_filename)
	{
		$param_File = HDSYS_DIR_SYS . 'cache/configs/' . $param_filename . '.config.php';
		if (file_exists($param_File)) {
			//return include($param_File);
			return $param_File;
		} else {
			return false;
		}
	}





	//传递参数用分析现成url地址
	public function GetTemplatesName($param_PATH_INFO = '')
	{


		//获取系统路由基本判断，规避完全后在数据库查找
		$param_arrars = GetNameAndLang($param_PATH_INFO);


		if ($param_arrars['templates'] != '') {
			return  $param_arrars;
		}


		$param_static_url = $param_arrars['name'];
		//这里做一个分割,如果有分页要把分页单独拿出来


		//读取栏目缓存信息
		$param_route  = 'mysql_route_' . call_my_md5($param_static_url);
		$param_array  = $this->GetFileArrayCodeCache($param_route);
		if ($param_array == true) {
			return include($param_array);
		}


		//这里后期需要写缓存现在先写好功能调用`id`,`template`,`static_url`
		$param_sql = "SELECT * FROM`hdsys_list`WHERE `static_url` = '{$param_static_url}'  LIMIT 1";
		$param_db_array = $this->intelligence_db->intelligence_array($param_sql);
		if ($param_db_array) {

			// if ($param_db_array['template_file'] != '') {
			// 	$param_db_array['template_file'] = '_' . $param_db_array['template_file'];
			// }
			//. $param_db_array['template_file']

			$param_arrars['templates'] = 'list.' . $param_db_array['template'];
			$param_arrars['array'] = $param_db_array;
			$param_arrars['weizhi'] = 'hdsys_list';
			$this->PushFileArrayCodeCache($param_route, $param_arrars);
			return $param_arrars;
		}


		//查询新闻
		$param_sql = "SELECT * FROM`hdsys_content`WHERE `static_url` = '{$param_static_url}' LIMIT 1";
		$param_db_array = $this->intelligence_db->intelligence_array($param_sql);
		if ($param_db_array) {

			$param_db_array['modules'] = json_decode($param_db_array['modules'], 1);
			$param_db_array['emodules'] = json_decode($param_db_array['emodules'], 1);


			#多加分类.
			$param_namearraylist = include(templates::intelligence_ClassificationlArray('all', -1));


			$param_pid_arr = explode(',', $param_db_array['pid']);
			$param_pid_obj = array();
			krsort($param_pid_arr);
			foreach ($param_pid_arr as $param_v) {
				if (isset($param_namearraylist[$param_v])) {
					$param_namearraylist[$param_v]['id'] = $param_v;
					$param_pid_obj[] = $param_namearraylist[$param_v];
				}
			}
			$param_db_array['nav'] = $param_pid_obj;

			$param_arrars['templates'] =   'content.' . $param_db_array['template'];
			$param_arrars['array'] = $param_db_array;
			$param_arrars['weizhi'] = 'hdsys_content';
			$this->PushFileArrayCodeCache($param_route, $param_arrars);

			return $param_arrars;
		}




		/* 自定义其他文件 */
		$param_arrars['templates'] =  $param_static_url;
		$param_arrars['array'] = array('id' => 0, 'pid' => 0);;
		$param_arrars['weizhi'] = 'oths';
		$this->PushFileArrayCodeCache($param_route, $param_arrars);
		return $param_arrars;
	}
}




// function intelligence_templates_Verifications()
// {
// 	$__SERVER__ = call_my_SERVER();
// 	$param_Bsphp_Host = null;
// 	$param_Bsphp_Key = null;
// 	$param_Bsphp_Key_MD5 = null;



// 	$param_key_dir__ = $__SERVER__[call_my_base64_decode("" . "SFRUUF9IT1NU")] . str_replace($__SERVER__[call_my_base64_decode("" . "RE9DVU1FTlRfUk9PVA==")], '', HDSYS_DIR_SYS);
// 	$param_key_dir__ = call_my_urlencode($param_key_dir__);



// 	//文件丢失B6001chr call_my_file_exists
// 	if (!file_exists(HDSYS_DIR_SYS . call_my_base64_decode("" . "RGF0YS8=") . $__SERVER__[call_my_base64_decode("" . "SFRUUF9IT1NU")] . call_my_base64_decode("" . "LnBocA=="))) {
// 		Bsphp_openssl_post_Verification();

// 		if (!file_exists(HDSYS_DIR_SYS . call_my_base64_decode("" . "RGF0YS8=") . $__SERVER__[call_my_base64_decode("" . "SFRUUF9IT1NU")] . call_my_base64_decode("" . "LnBocA=="))) {
// 			bs_lib::Alerts(call_my_base64_decode("" . "5paH5Lu25Lii5aSxQjYwMDE="), call_my_base64_decode("" . "5oyH5a6a5paH5Lu25Lii5aSxOkRhdGHnm67lvZXmsqHmnInmo4DmtYvliLDmnInmjojmnYPmlofku7Ys56Gu6K6kRGF0YeebruW9leWGmeWFpeWxnuaApyA3NzfvvIE="), 1); //判断文件是否存在
// 		}
// 		//  include (HDSYS_DIR_SYS . 'Data/data.php');
// 	}
// 	$param_key_code_txt = call_my_include(HDSYS_DIR_SYS . call_my_base64_decode("" . "RGF0YS8=") . $__SERVER__[call_my_base64_decode("" . "SFRUUF9IT1NU")] . call_my_base64_decode("" . "LnBocA=="));




// 	$param_pieces = call_my_explode("|", $param_key_code_txt);

// 	//判断返回是否正确认证失败B7008chr
// 	$param_count = call_my_count($param_pieces);
// 	// PRINT_r($param_pieces);
// 	if ($param_count < 3) {
// 		Bsphp_openssl_post_Verification();
// 		bs_lib::Alerts(call_my_base64_decode("" . "6K6k6K+B5aSx6LSlQjcwMDg="), call_my_base64_decode("" . "5o6I5p2D5paH5Lu2LOiiq+mdnuazleS4suaUuSzor7fph43mlrDnmbvlvZXlkI7lj7Av5oiW6ICF5Yiw5o6I5p2D5bmz5Y+w5LiL6L295o6I5p2DS0VZ6Kej5Yaz5q2k6Zeu6aKY77yB"), 1);
// 	}
// 	$param_Bsphp_Host = $param_pieces[2];
// 	$param_Bsphp_Key = $param_pieces[0];;
// 	$param_Bsphp_Key_MD5 = $param_pieces[1];;



// 	//效验 判断数据是否被非法串改 认证失败B6002chr
// 	$param_Key_MD5 = call_my_md5(call_my_base64_decode("" . "OGZjYTMwZWYwYWUxYjhlODA4ZThmY2EzMGVmMGFlMWI4ZTgwOGUg") . call_my_strtolower($param_Bsphp_Host) . $param_Bsphp_Key . call_my_base64_decode("" . "MDUzMmFmOWMyN2NkOWFjYzk4NTMz"));
// 	if ($param_Bsphp_Key_MD5 != $param_Key_MD5) {
// 		bs_lib::Alerts(call_my_base64_decode("" . "6K6k6K+B5aSx6LSlQjYwMDI="), call_my_base64_decode("" . "5o6I5p2D5paH5Lu2LOiiq+mdnuazleS4suaUuSDooqvpnZ7ms5XkuLLmlLks6K+36YeN5paw55m75b2V5ZCO5Y+wL+aIluiAheWIsOaOiOadg+W5s+WPsOS4i+i9veaOiOadg0tFWeino+WGs+atpOmXrumimO+8gQ=="), 1);
// 	}

// 	//$encrypt_Key_MD5 = MD5('8fca30ef0ae1b8e808e8fca30ef0ae1b8e808e ' . strtolower($__SERVER__['HTTP_HOST']) . $param_pieces[1] . '0532af9c27cd9acc98533');
// 	//判断域名不一直返回状态信息  and $param_Verification == 'host_appen'
// 	if (call_my_strtolower($__SERVER__[call_my_base64_decode("" . "SFRUUF9IT1NU")]) != $param_Bsphp_Host) {
// 		return '';
// 	}


// 	//验证域名是否一致//域认证名不符B6003chr
// 	if (call_my_strtolower($__SERVER__[call_my_base64_decode("" . "SFRUUF9IT1NU")]) != $param_Bsphp_Host) {
// 		bs_lib::Alerts(call_my_base64_decode("" . "5Z+f6K6k6K+B5ZCN5LiN56ymQjYwMDM="), call_my_base64_decode("" . "5b2T5YmN5Z+f5ZCN5LiO5L2g6K6k6K+B5Z+f5ZCN5LiN56ym5ZCI44CC"), 1);
// 	}


// 	//解密
// 	$param_mystring = Bsphp_decrypt($param_Bsphp_Key, call_my_md5(call_my_strtolower($__SERVER__[call_my_base64_decode("" . "SFRUUF9IT1NU")]) . call_my_base64_decode("" . "ODMxNmJkZmUwMDhjNDE0YWYwNTliNGJkNDA5NzI3NjY=") . $param_Bsphp_Host));

// 	//判断解密是否成功 认证失败B6004chr
// 	$param_pos = call_my_strstr($param_mystring, call_my_base64_decode("" . "T0t8"));
// 	if ($param_pos == false) {
// 		bs_lib::Alerts(call_my_base64_decode("" . "6K6k6K+B5aSx6LSlQjYwMDQ="), call_my_base64_decode("" . "5peg5rOV6YCa6L+H6K6k6K+BLEtleeWvhumSpeS4jeato+ehruOAguivt+WwneivlemHjeaWsOeZu+W9leeuoeeQhuWQjuWPsOino+WGs+atpOmXrumimO+8gQ=="), 1);
// 	}


// 	$param_pieces = call_my_explode(call_my_base64_decode("" . "fA=="), $param_mystring);

// 	if (isset($param_pieces[13])) {
// 		return $param_pieces[13];
// 	} else {
// 		return call_my_int_0();
// 	}
// }
